On 23/09/12 22:09, Chris Fallin wrote:

> I'm getting a perplexing error message with Valgrind. I get an
> "invalid read of size 8", but the address is inside an allocated block
> (and the access size doesn't go out-of-bounds). The access goes
> through fine but I'm debugging a segfault much later in execution (the
> reason I started using Valgrind just now and saw a bunch of these
> errors). I'm wondering if maybe there's some other reason I would see
> this message:
>
>
> ==16432== Invalid read of size 8
> ==16432==    at 0x43319E: trampoline() (thread.cc:134)
> ==16432==  Address 0x646b5d8 is 56 bytes inside a block of size 72 alloc'd
> ==16432==    at 0x4C285A4: operator new(unsigned long) 
> (vg_replace_malloc.c:298)
> ==16432==    by 0x432EFF: thread_new(void (*)(void*, void*, void*),
> void*, void*, void*, unsigned long, int) (thread.cc:142)
> [ snip internal stuff ]
> ==16432==    by 0x4083AF: main (main.cc:210)
>
> If it's relevant, this is inside a little
> userspace-cooperative-threads package I wrote and the code is running
> on a malloc()'d stack.

At a guess you're reading below the stack pointer.

Assuming that the block it is complaining about is the block that your 
user space thread is using as stack what is happening is that when the 
stack is popped valgrind will mark the stack below the stack pointer as 
invalid, and then if you try and read it you will get that error.

Tom

-- 
Tom Hughes ([email protected])
http://compton.nu/

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://ad.doubleclick.net/clk;258768047;13503038;j?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to