Memory Fault Question.

Hello,

Can anyone explain why a program will not crash with debug info on, but
will
Memory Fault with it off at 0007:00002000?

Thanks,
Tom.

“Tom” <pwc@ag-signs.com> wrote in message news:aoklqb$6rt$1@inn.qnx.com

Hello,


Can anyone explain why a program will not crash with debug info on, but
will Memory Fault with it off at 0007:00002000?

Compiling with debug info results in different code being generated. Plus
the layout in memory is different.

Look at the map file (-M option to cc) to give you an idea what function
lives at 0007:0002000

Thanks,
Tom.

Hi,

Previously, you (Mario Charest) wrote:

“Tom” <> pwc@ag-signs.com> > wrote in message news:aoklqb$6rt$> 1@inn.qnx.com> …
Hello,


Can anyone explain why a program will not crash with debug info on, but
will Memory Fault with it off at 0007:00002000?

Compiling with debug info results in different code being generated. Plus
the layout in memory is different.

Look at the map file (-M option to cc) to give you an idea what function
lives at 0007:0002000

I believe the chance of a function living at address 00002000 is rather small,
since code addresses usually start way above that.

Besides that, an ‘address’ as even as 00002000 makes me suspicious.

More likely, the 00002000 will result from a return address being overwritten
within a function. Since runtime information for debugging will occupy some space
on the stack, the information being overwritten might be less… vital.

A strong guess is that there is a local array in that function, and that it’s
bounds are exceeded in some writing operation, like

void f( int idx, int val )
{
int a[1];

a[idx] = val;
}


f( 0, 0x00001000 ); /* ok /
f( 1, 0x00002000 ); /
crash */

Thanks,
Tom.

Regards,


T. Haupt

Just because there’s a bug in the program, doesn’t nessessarily
mean it will crash. For example a buffer overrun may go beyond
your data segment (SIGSEGV) or may just overwrite other
data. That’s probably the case with your debug version.

Can anyone explain why a program will not crash with debug info on, but
will
Memory Fault with it off at 0007:00002000?

Thanks,
Tom.