|
From: Jeremy F. <je...@go...> - 2003-11-01 21:33:03
|
On Fri, 2003-09-26 at 20:46, Avery Pennarun wrote: > I have a fun problem with valgrind in the WvTask part of my WvStreams > library (http://open.nit.ca/wiki?WvStreams). I can make a minimal test case > for you if necessary, but the idea is this: > > setjmp(top); > alloca(1024*1024); // reserve space on stack for toplevel > setjmp(inside); > longjmp(top); > > This allows me to allocate "extra stacks" within my own primary stack, > rather than writing arch-specific stack changing code that uses malloc(). Do you do something special with signals here (like block them all, or use a sigaltstack)? If not, then a signal could come in and trash whatever is below %esp at any time. On some systems/CPUs, it could be a quite lot of memory (>4k). > But in my case, I need the area below %esp to not be marked inaccessible. I > really want only the memory below *the minimum historical value of %esp* to > be inaccessible. In general, everything below the current %esp is considered to have undefined values because the kernel may trash it at any time. You'd probably be better off just allocating a chunk of memory and using that for stacks. It takes about as much time to extend the stack by 1MByte as do a malloc/brk/mmap to explicitly allocate the memory (it may even be faster to do a syscall than take the page fault trap). J |