question about memory overflow

hello all:
i miss that process terminate when my program run , screen display
"processname run terminated(SIGSEGV) at 0005:00054FD7 ".
i think that memory overflow lead this occur .i don.t know whether this idea is right .please give me some suggest!
my experience at checking source-code is lacking , please tell me some experience or tools checking source-code ,thanks in advance!

you are right,
SIGSEGV = segmentation fault,
so for example if you allocate an array of 10 elements and then you try to access the 20th element you will probably get a SIGSEGV.

IMHO most cases of SIGSEGV are caused by pointers that are not allocated at all! so for example you use some allocation function like this:[code]/** allocation function

  • return a pointer to the allocated array
  • return NULL when error occured
    */
    char * my_alloc(int size); [/code]
    and later:

char * my_ptr; my_ptr=my_alloc(10); my_ptr[0]='A';
then make sure my_alloc() does not return NULL when an error occured. Because then my_ptr would be NULL and my_ptr[0] would try to access some memory not available and this would lead to SIGSEGV.
so make sure to check the pointer:

char * my_ptr; my_ptr=my_alloc(10); if (my_ptr!=NULL) { my_ptr[0]='A'; }
Hope you understand what I want to say…

thanks SmeeAgain :
how to checking whether source-code include memory overflow?
are there some tool?please tell me some experience or tools checkingsource-code ,thanks in advance!

carefull reading :wink:

I am not aware of any tools to check your sourcecode, but how about running your app in a debugger?
I never really used QNX 4 myself, but e.g. in QNX 6 you can use gdb to debug your program. You would then see the line of code where the SIGSEGV occured.

I think wd is the standard debugger for QNX 4, but I am not sure about this though.

Compile your code with -g2. Start dumper, then start your application, when it crashes dumper will detected it and create a dump file.

Then load that dump file with the debugger wd -trap=pmd file.dmp and the debugger should pop up with the cursor right on the offending line of code.