|
From: Joshua Moore-O. <jo...@ch...> - 2005-06-02 00:12:12
|
My question relates to the trailing valgrind output snippet. I cannot see what the problem is. Invalid read of size 4 Ok, as far as I understand this a read of size 4 is going outside of valid memory (be it stack or malloc'd memory) Address 0x1BB4C834 is 260 bytes inside a block of size 764 alloc'd So, valgrind goes on to tell me that this is WELL inside the block of 764 bytes allocated... 260 + 4 == 264 < 764, it seems to be well inside the boundaries of the allocated memory space. I have the same output using both valgrind 2.2.0 and 2.4.0 ==21823== Invalid read of size 4 ==21823== at 0x1BA5BEA1: swapcontext (in /lib/libc-2.3.4.so) ==21823== Address 0x1BB4C834 is 260 bytes inside a block of size 764 alloc'd ==21823== at 0x1B905C2C: malloc (vg_replace_malloc.c:131) ==21823== by 0x1B90E827: __pth_tcb_alloc (in /home/chatgris/code/university/USRA/S05/pth-2.0.0-install-pthread/lib/libpth.so.20.0.20) ==21823== by 0x1B910E0F: pth_spawn (in /home/chatgris/code/university/USRA/S05/pth-2.0.0-install-pthread/lib/libpth.so.20.0.20) ==21823== by 0x80489FE: main (in /home/chatgris/code/university/USRA/S05/cspdebug/a.out) Any help understanding this output would be appreciated. Thanks, Joshua Moore-Oliva |
|
From: Nicholas N. <nj...@cs...> - 2005-06-02 00:38:18
|
On Wed, 1 Jun 2005, Joshua Moore-Oliva wrote: > My question relates to the trailing valgrind output snippet. I cannot see what the problem is. > > Invalid read of size 4 > > Ok, as far as I understand this a read of size 4 is going outside of valid memory (be it stack or malloc'd memory) > > Address 0x1BB4C834 is 260 bytes inside a block of size 764 alloc'd > > So, valgrind goes on to tell me that this is WELL inside the block of 764 bytes allocated... 260 + 4 == 264 < 764, it seems to be well inside the boundaries > of the allocated memory space. Is there any way Memcheck could be lead to think the memory in the middle of the block is not accessible? Eg. mprotect() was called on it? It may also be a Memcheck bug. If you could make a reproducible test case that would be great. Nick |
|
From: Joshua Moore-O. <jo...@ch...> - 2005-06-02 19:12:45
|
> Is there any way Memcheck could be lead to think the memory in the middle > of the block is not accessible? Eg. mprotect() was called on it? I looked through my source code and grepped the source code of pth (the userland threads package I am using) and there are no mprotect calls. > > It may also be a Memcheck bug. If you could make a reproducible test case > that would be great. I have one here. It needs to be compiled with pth which can be retrieved from http://www.gnu.org/software/pth #include <pth.h> #include <iostream> void * entry( void * arg ) { if ( arg == NULL ) { std::cout << "arg is null" << std::endl; } else { std::cout << "arg is not null" << std::endl; } pth_sleep( 15 ); return NULL; } int main () { pth_init(); pth_t pid = pth_spawn( PTH_ATTR_DEFAULT , entry , NULL ); if ( pid == NULL ) { std::cerr << "Error in pth_spawn" << std::endl; } pth_join( pid , NULL ); pth_kill(); return 0; } Thanks, Joshua Moore-Oliva |
|
From: Jeremy F. <je...@go...> - 2005-06-02 20:27:04
|
Nicholas Nethercote wrote:
> Is there any way Memcheck could be lead to think the memory in the
> middle of the block is not accessible? Eg. mprotect() was called on it?
>
> It may also be a Memcheck bug. If you could make a reproducible test
> case that would be great.
mprotect shouldn't affect addressability.
Joshua: The only thing I can think of is whether you are using any of
the VALGRIND_* macros in your program? How are you invoking Valgrind?
J
|
|
From: Joshua Moore-O. <jo...@ch...> - 2005-06-02 20:45:49
|
> mprotect shouldn't affect addressability. > > Joshua: The only thing I can think of is whether you are using any of > the VALGRIND_* macros in your program? How are you invoking Valgrind? I wasn't using any VALGRIND_* macros in my program. Your later message talked about swapcontext... So swapcontext cannot be used reliably with valgrind without patching valgrind and modifying the code that uses swapcontext? Is this correct? Josh. |
|
From: Robert W. <rj...@du...> - 2005-06-02 21:00:58
|
> So swapcontext cannot be used reliably with valgrind without > patching valgrind and modifying the code that uses swapcontext? > Is this correct? Yes, but I'll be pushing these changes back to both the 2.4 and 3.0 line this weekend, after I write some documentation, so it'll all be "official." Regards, Robert. |