W
whiskers
I'm debugging some code and I have to admit that I don't know yet how
it works.
But I ran into a problem I can't explain
The program is a DLL that retrieves raw data from a camera, builds
histograms based on the pixel values, and displays them on the screen;
here's a small excerpt:
VOID CHistogramContainer::appendFrameData(WORD *pdwRawData, int nWidth,
int nHeight)
{
int nPixelPos;
__int64 total;
__int64 median;
double accuVar;
for (UINT i = m_nVStart; i <= m_nVEnd; i++) {
for (UINT j = m_nHStart; j <= m_nHEnd; j++) {
// Becareful! pixelval is value of pixel and
// index for distribution as well
int pixelval = *(pdwRawData+((i-1)*nWidth+j));
The last line always returns an unhandled exception. When I try to see
what value (i-1)*nWidth+j is equal to, it's always the same somewhere
along the lines of -809601 or something (and nWdith always = 1920).
First of all, i starts at 0, so I don't think i-1 is even a valid value
here.
Anyway, what baffles me is that if I create a new variable such as int
pixel = 0; I get an unhandled exception!! If I initialize accuVar to a
value, the initialization does not work!
What is causing this strange behavior, is it a memory issue? How is it
possible to get get an unhandled exception when initializing a
variable? I really know little of how this DLL works, but the trivial
task of adding a variable shouldn't be so bizarre, should it?
it works.
But I ran into a problem I can't explain
The program is a DLL that retrieves raw data from a camera, builds
histograms based on the pixel values, and displays them on the screen;
here's a small excerpt:
VOID CHistogramContainer::appendFrameData(WORD *pdwRawData, int nWidth,
int nHeight)
{
int nPixelPos;
__int64 total;
__int64 median;
double accuVar;
for (UINT i = m_nVStart; i <= m_nVEnd; i++) {
for (UINT j = m_nHStart; j <= m_nHEnd; j++) {
// Becareful! pixelval is value of pixel and
// index for distribution as well
int pixelval = *(pdwRawData+((i-1)*nWidth+j));
The last line always returns an unhandled exception. When I try to see
what value (i-1)*nWidth+j is equal to, it's always the same somewhere
along the lines of -809601 or something (and nWdith always = 1920).
First of all, i starts at 0, so I don't think i-1 is even a valid value
here.
Anyway, what baffles me is that if I create a new variable such as int
pixel = 0; I get an unhandled exception!! If I initialize accuVar to a
value, the initialization does not work!
What is causing this strange behavior, is it a memory issue? How is it
possible to get get an unhandled exception when initializing a
variable? I really know little of how this DLL works, but the trivial
task of adding a variable shouldn't be so bizarre, should it?