zorba has severe issues when compiled with GCC 4.9.0
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zorba |
Fix Committed
|
Undecided
|
Paul J. Lucas |
Bug Description
I currently try to prepare Zorba for Fedora 21 which requires to build all packages with GCC 4.9.0. The code compiles without errors but the resulting binary has severe issues when one of the optimization options -O1, -O2, or -O3 are applied. It segfaults on any query due to multiple deallocation of the same memory. Initially, I thought that there must be a regression in GCC's optimizer but after analyzing the issue, I guess that some of Zorba's utility classes are the origin.
I tracked down the segfault for the simple query "1" (see attached patch) but there are still a lot more issues in the code that lead to similar problems. Since I don't know the implementation details of Zorba, it would be great if one of the Zorba experts could dig into code and help to fix it.
Here's the output of GCC's address sanitizer written when Zorba executes the bundled test query test/rbkt/
==17767==ERROR: AddressSanitizer: heap-use-after-free on address 0x61400000aa50 at pc 0x7f3caa205da9 bp 0x7fff38c445e0 sp 0x7fff38c445d0
READ of size 8 at 0x61400000aa50 thread T0
#0 0x7f3caa205da8 in zorba::
#1 0x7f3caa205da8 in zorba::
#2 0x7f3ca97d6e50 in ~ItemHandle /builddir/
#3 0x7f3ca97d6e50 in ~ForVarState /builddir/
#4 0x7f3ca97d6e50 in zorba::
#5 0x7f3ca97d6e50 in zorba::
#6 0x7f3ca95f091e in zorba::
#7 0x7f3ca95f091e in zorba::
#8 0x7f3ca9a045c5 in zorba::
#9 0x7f3ca9a045c5 in zorba::
#10 0x7f3ca95a8c0b in zorba::
#11 0x7f3ca95a8c0b in zorba::
#12 0x7f3ca7be3904 in zorba::
#13 0x417ed9 in compileAndExecu
#14 0x4088fb in main /builddir/
#15 0x7f3c9e1960bf in __libc_start_main (/lib64/
#16 0x40cdf6 (/builddir/
0x61400000aa50 is located 16 bytes inside of 432-byte region [0x61400000aa40
freed by thread T0 here:
#0 0x7f3cb0e45a1f in operator delete(void*) (/lib64/
#1 0x7f3ca97d6e50 in ~ItemHandle /builddir/
#2 0x7f3ca97d6e50 in ~ForVarState /builddir/
#3 0x7f3ca97d6e50 in zorba::
#4 0x7f3ca97d6e50 in zorba::
previously allocated by thread T0 here:
#0 0x7f3cb0e4551f in operator new(unsigned long) (/lib64/
#1 0x7f3caa4fabcf in zorba::
SUMMARY: AddressSanitizer: heap-use-after-free /builddir/
Changed in zorba: | |
status: | New → In Progress |
Changed in zorba: | |
status: | In Progress → Fix Committed |
Thanks for your good patch. We've applied it. As for the rest, I am able to reproduce a similar problem using Mac OS X and a MacPorts prerelease version of gcc 4.9. However, the core dump it produces isn't useful: gdb complains that it can't unwind the stack past a certain point. It doesn't actually matter whether any -O option is given: it fails regardless.
I also tried gcc 4.8 and it runs fine under Linux (Ubuntu), but also fails on Mac. Ubuntu currently doesn't have a gcc 4.9 available. We could try compiling it from source, but that will take some effort.