[lug] Linux protected memory question
Tom Tromey
tromey at redhat.com
Thu Dec 5 17:04:11 MST 2002
>>>>> "Daniel" == Daniel Webb <webb at danielwebb.us> writes:
Daniel> Is memory malloc'ed by a shared library in the same protected
Daniel> memory area (is this called a segment?) as the calling
Daniel> program?
Yes.
Daniel> In other words, if my shared library gets some malloc'ed
Daniel> memory, can the program that links with my library change that
Daniel> malloc'ed memory without detection, or will it guarantee a
Daniel> segmentation fault?
If the memory was allocated then on a Unix system you're pretty much
guaranteed that there *won't* be a segmentation fault.
On a Unix system all the code running in a given process shares the
same heap. The origin of the code doesn't matter.
Daniel> Also, what techniques do people here use for assertions and
Daniel> debug messages.
In gcc the standard is to just call abort() if a problem is found.
The theory is, you'll need to use the debugger to find the problem
anyway. For gcc this is an excellent strategy, but then it is ok for
gcc to crash from time to time.
Tom
More information about the LUG
mailing list