plasma-umass / coz

Coz: Causal Profiling
Other
4.04k stars 160 forks source link

free(): invalid pointer #149

Closed yxhuvud closed 4 years ago

yxhuvud commented 4 years ago

So, I am trying to create coz bindings for Crystal. I'm running into this error that I don't really understand.

I am getting a whole bunch of the following error, often past the stage where the profiled parts is actually located:

free(): invalid pointer           
Aborted!
  0: /usr/lib/coz-profiler/libcoz.so(_ZN8profiler8on_errorEiP9siginfo_tPv+0x67) [0x7fed6dca1e17]
  1: /lib/x86_64-linux-gnu/libpthread.so.0(+0x15540) [0x7fed6a907540]
  2: /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb) [0x7fed6a4c93eb]
  3: /lib/x86_64-linux-gnu/libc.so.6(abort+0x12b) [0x7fed6a4a8899]
  4: /lib/x86_64-linux-gnu/libc.so.6(+0x9038e) [0x7fed6a51338e]
  5: /lib/x86_64-linux-gnu/libc.so.6(+0x984dc) [0x7fed6a51b4dc]
  6: /lib/x86_64-linux-gnu/libc.so.6(+0x99cfc) [0x7fed6a51ccfc]
  7: /lib64/ld-linux-x86-64.so.2(_dl_deallocate_tls+0x3d) [0x7fed6df14e8d]
  8: /lib/x86_64-linux-gnu/libpthread.so.0(+0x82a2) [0x7fed6a8fa2a2]
  9: /lib/x86_64-linux-gnu/libpthread.so.0(+0x9582) [0x7fed6a8fb582]
  10: /lib/x86_64-linux-gnu/libpthread.so.0(+0xab52) [0x7fed6a8fcb52]
  11: /usr/lib/coz-profiler/libcoz.so(_exit+0x10) [0x7fed6dc9a560]
  12: /home/linus/prog/crystal/.build/crystal(~procProc(Nil)+0x274) [0x6c0a14]
  13: /home/linus/prog/crystal/.build/crystal(*Fiber#run:(IO::FileDescriptor | Nil)+0x73) [0x7c3ad3]
  14: /home/linus/prog/crystal/.build/crystal(~procProc(Fiber, (IO::FileDescriptor | Nil))+0x6) [0x6be236]

Things I know: 0: Crystal is using libgc, which is a conservative GC. 1: I am not running out of memory or disk, so no failed allocations. 2: I am keeping references to everything I allocate on my side, so it should not be a case of GC error on my side.

I'm at a loss when it comes to figuring out the actual issue here. Is it the GC that finds some memory allocated by coz that it (invalidly) think should be freed, or is it some pthread or ld issue? I'm afraid my C chops isn't strong enough to figure out the answer to that question.