Mail Archives: djgpp/2004/10/08/07:52:12
> From: "JC" <jessechao AT comcast DOT net>
> Date: Thu, 7 Oct 2004 22:57:08 -0700
>
> p = (UINT8 *)malloc(len+1);
> if (p == NULL)
> {
> ...
> }
> dosmemget(addr, len, p);
> /* Code to printf the contents in *p */
> ...
> free(p);
>
> The code compiled & ran fine. But when the code execute
> the free(). The code crashed and got SIGSEG error:
>
> Exiting due to signal SIGSEGV
> General Protection Fault at eip=00006ac4
> ...
>
> According to the FAQ, this might happen if the code put
> data into the buffer that is longer than malloc.
Or because it overwrote the buffer's end during processing.
Overall, I agree with the suggestion already posted here: show more of
your code between the calls to dosmemget and free, the problem is
likely somewhere there.
You could also debug this problem yourself, e.g. by setting a
data-write breakpoint (a.k.a. watchpoint) at the end of the buffer
allocated with malloc, and then see if some code except dosmemget
writes there.
- Raw text -