Mail Archives: djgpp/1997/06/19/06:49:24
> POSIX is pretty vague about EFAULT because, as it claims, "not all
> systems can reliably detect it."
We could do several things to improve our detection:
1) provide a function to check pointers to be in the valid address range.
This would have to check the limits of each allocated memory zone.
This would prevent nearptr hacks outside the normal address space
or other unusual things from being valid. The pointer plus length
should also be checked - but if it's null terminated this can't be
done with this method. If the length was huge this method also might
fail if the start and end spanned non-contiguous memory zones. This
method would catch some access to memory spanned by non-contig memory
zone which will not generate a fault normally.
2) establish a signal handler when entering the function to longjmp back
to an exit point and set the fault code. This will catch all the
bad adresses which would cause a fault (but not necessarily illegally
addressed spanned memory), but may leave the funtion in a half-done
state. This could probably be done as a nice function setup fairly
easily.
So - is it worth it?
- Raw text -