View Single Post
  #5   (View Single Post)  
Old 18th September 2011
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by xmorg View Post
H...the program crashes(in the middle of writing a region).... some kinda overflow? what is it? Ive tried fputc, and fputs... hmmm.
We haven't seen the code, so it is difficult to say what is the root cause, but things you will want to explore include:
  • Ensure all regions have been initialized. It appears you are doing a lot of dereferencing in your code, &:
    • reading from a nonzero random address will yield garbage. At this point, it becomes a question of whether the bit patterns found at such addresses yield valid values.
    • writing to nonzero random addresses will generate a fault.
    Your structures contain many string addresses. If these addresses have not been initialized or assigned the address of memory acquired through malloc(), etc, then they are uninitialized as well.
  • Look at how much data is on the stack. At compilation, the size of the stack will be set. For "normal" usage, the system default should be adequate, but like all C-like arrays, array boundaries can be exceeded.
My suggestion is to write code which will output a region to stdout, or at least chosen parts. The purpose of this is to provide you a means of validating any arbitrary region structure which is being maintained. Until you can say with certainty that all structures contain expected data, dereferencing problems will continue to lurk.
Reply With Quote