Recent

Author Topic: Valgrind and cthreads problem  (Read 3738 times)

Tor

  • Newbie
  • Posts: 6
Valgrind and cthreads problem
« on: December 13, 2015, 01:26:05 am »
Hi, I tried to debug a heap corruption with valgrind in a multithreaded freepascal project. It failed with a (for me) wierd error, so I made a minimal program with cthreads:

Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. uses cthreads;
  4.  
  5. begin
  6.   writeln('Hello World');
  7. end.
  8.  

Which fails like that (command: valgrind ./project1):

Code: [Select]
==17843== Memcheck, a memory error detector
==17843== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==17843== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==17843== Command: ./project1
==17843==
vex amd64->IR: unhandled instruction bytes: 0x8F 0xEA 0xF8 0x10 0xC9 0x3 0x1D 0x0
vex amd64->IR:   REX=0 REX.W=0 REX.R=0 REX.X=0 REX.B=0
vex amd64->IR:   VEX=0 VEX.L=0 VEX.nVVVV=0x0 ESC=NONE
vex amd64->IR:   PFX.66=0 PFX.F2=0 PFX.F3=0
==17843== valgrind: Unrecognised instruction at address 0x4011d04.
==17843==    at 0x4011D04: _dl_allocate_tls_storage (in /lib64/ld-2.22.so)
==17843==    by 0x4000B9A: init_tls (in /lib64/ld-2.22.so)
==17843==    by 0x40034AF: dl_main (in /lib64/ld-2.22.so)
==17843==    by 0x4016978: _dl_sysdep_start (in /lib64/ld-2.22.so)
==17843==    by 0x4004C28: _dl_start (in /lib64/ld-2.22.so)
==17843==    by 0x4000C47: ??? (in /lib64/ld-2.22.so)
==17843== Your program just tried to execute an instruction that Valgrind
==17843== did not recognise.  There are two possible reasons for this.
==17843== 1. Your program has a bug and erroneously jumped to a non-code
==17843==    location.  If you are running Memcheck and you just saw a
==17843==    warning about a bad jump, it's probably your program's fault.
==17843== 2. The instruction is legitimate but Valgrind doesn't handle it,
==17843==    i.e. it's Valgrind's fault.  If you think this is the case or
==17843==    you are not sure, please let us know and we'll try to fix it.
==17843== Either way, Valgrind will now raise a SIGILL signal which will
==17843== probably kill your program.
==17843==
==17843== Process terminating with default action of signal 4 (SIGILL)
==17843==  Illegal opcode at address 0x4011D04
==17843==    at 0x4011D04: _dl_allocate_tls_storage (in /lib64/ld-2.22.so)
==17843==    by 0x4000B9A: init_tls (in /lib64/ld-2.22.so)
==17843==    by 0x40034AF: dl_main (in /lib64/ld-2.22.so)
==17843==    by 0x4016978: _dl_sysdep_start (in /lib64/ld-2.22.so)
==17843==    by 0x4004C28: _dl_start (in /lib64/ld-2.22.so)
==17843==    by 0x4000C47: ??? (in /lib64/ld-2.22.so)
==17843== Jump to the invalid address stated on the next line
==17843==    at 0x596: ???
==17843==  Address 0x596 is not stack'd, malloc'd or (recently) free'd
==17843==
==17843==
==17843== Process terminating with default action of signal 11 (SIGSEGV)
==17843==  Bad permissions for mapped region at address 0x596
==17843==    at 0x596: ???
==17843==
==17843== HEAP SUMMARY:
==17843==     in use at exit: 0 bytes in 0 blocks
==17843==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==17843==
==17843== All heap blocks were freed -- no leaks are possible
==17843==
==17843== For counts of detected and suppressed errors, rerun with: -v
==17843== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault


Without cthreads valgrind works fine, but this is the first time I use valgrind so maybe I miss debug-packages for something other than glibc? Are others having the same error and this is a bug to be reported to either valgrind or freepascal? Or is this just me being stupid?

Additional info: I use fpc-3.0.0 on Gentoo Linux (amd64) with glibc-2.22

Tor

  • Newbie
  • Posts: 6
Re: Valgrind and cthreads problem
« Reply #1 on: December 13, 2015, 05:32:16 pm »
After some sleep and research I realized it is a valgrind bug, which pops up whenever dynamic linking is used.

 

TinyPortal © 2005-2018