|
From: Xiaolei H. <xh...@sc...> - 2003-06-01 02:13:17
|
Hi, all, When I tried the valgrind with my problem, the valgrind always gets = crashed with a "segmentation fault" as soon as I perfomed a particular = operation.=20 However, the program doesn't crash itself if it runs alone. I highly = suspect=20 something wrong with my problem, I just don't know what it is. The last=20 three pieces of valgrind commentary are interesting. Here they are: =3D=3D24934=3D=3D Thread 23: =3D=3D24934=3D=3D Invalid read of size 4 =3D=3D24934=3D=3D at 0x842E800: PThread::PX_ThreadEnd(void*) = (tlibthrd.cxx:1054) =3D=3D24934=3D=3D by 0x4027D836: _pthread_cleanup_pop = (vg_libpthread.c:844) =3D=3D24934=3D=3D by 0x842E7E5: PThread::PX_ThreadStart(void*) = (tlibthrd.cxx:1045) =3D=3D24934=3D=3D by 0x4027D41C: thread_wrapper = (vg_libpthread.c:671) =3D=3D24934=3D=3D Address 0x4017E9FA4 is 40 bytes inside a block of = size 141 free'd =3D=3D24934=3D=3D at 0x4015E5A5: free (vg_clientfuncs.c:185) =3D=3D24934=3D=3D by 0x8442CCE: PMemoryHeap::Deallocated(void*, char = const*) (../common/object.cxx:647) =3D=3D24934=3D=3D by 0x831A62B: H225TransportThread::operator = delete(void*) (transports.cxx:466) =3D=3D24934=3D=3D by 0x8318D22: = H225TransportThread::~H225TransportThread() = (/usr/include/c++/3.2/iostream:62) =3D=3D24934=3D=3D=20 =3D=3D24934=3D=3D Thread 23: =3D=3D24934=3D=3D Invalid read of size 4 =3D=3D24934=3D=3D at 0x842E80B: PThread::PX_ThreadEnd(void*) = (tlibthrd.cxx:1054) =3D=3D24934=3D=3D by 0x4027D836: _pthread_cleanup_pop = (vg_libpthread.c:844) =3D=3D24934=3D=3D by 0x842E7E5: PThread::PX_ThreadStart(void*) = (tlibthrd.cxx:1045) =3D=3D24934=3D=3D by 0x4027D41C: thread_wrapper = (vg_libpthread.c:671) =3D=3D24934=3D=3D Address 0xA5A5A609 is not stack'd malloc'd or = free'd =3D=3D24934=3D=3D=20 =3D=3D24934=3D=3D Thread 23: =3D=3D24934=3D=3D Jump to the invalid address stated on the next line =3D=3D24934=3D=3D at 0x0: ??? =3D=3D24934=3D=3D by 0x4027D836: _pthread_cleanup_pop = (vg_libpthread.c:844) =3D=3D24934=3D=3D by 0x842E7E5: PThread::PX_ThreadStart(void*) = (tlibthrd.cxx:1045) =3D=3D24934=3D=3D by 0x4027D41C: thread_wrpper (vg_libpthread.c:671) =3D=3D24934=3D=3D Address 0x0 is not stack'd, malloc'd or free'd I do understand, based on section 2.4 of valgrind documentation, that if = "your=20 program attemps to read from address zero, the skin will emit a message = to=20 this effect, and the program will then duly die with a segmentation = fault". What=20 I don't understand is that why my program doesn't crash itself when it = is running alone. What should I do to get it working? Your advice is highly = appreciated. Lei |
|
From: Nicholas N. <nj...@ca...> - 2003-06-01 13:59:01
|
On Sat, 31 May 2003, Xiaolei Hao wrote: > When I tried the valgrind with my problem, the valgrind always gets crashed > with a "segmentation fault" as soon as I perfomed a particular operation. > However, the program doesn't crash itself if it runs alone. When you run your program under Valgrind, it's behaviour isn't preserved exactly -- things like thread scheduling and memory layouts can be a bit different. Your original program might not crash due to luck. Since the jump to 0x0 occurs from within _pthread_cleanup_pop, it looks like you might have accidentally registered a NULL cleanup handler with pthread_cleanup_push? Could this have happened? (If so, I'm not sure why your program wouldn't crash normally... it might be a bug in Valgrind, but I would try to fix the three errors Valgrind claims to see first. Chances are if you do that it won't crash under Valgrind anymore, and you can be more confident it won't crash randomly when run normally.) N |