VM crashes in libexecinfo on FreeBSD #272

Closed
marius opened this Issue Apr 24, 2010 · 4 comments

Comments

Projects
None yet
3 participants
@marius
Contributor

marius commented Apr 24, 2010

I have to disable usage of libexecinfo on FreeBSD for the default rake task to work without errors. I did this by commenting line 437 of the configure script. If I don't do this it builds fine but crashes in the c++ test runner in files test_exception.hpp line 24 and test_object.hpp line 63. Here is a backtrace:

% gdb vm/test/runner runner.core
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...
Core was generated by `runner'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libthr.so.3...done.
Loaded symbols for /lib/libthr.so.3
Reading symbols from /lib/libcrypt.so.5...done.
Loaded symbols for /lib/libcrypt.so.5
Reading symbols from /usr/local/lib/libexecinfo.so.1...done.
Loaded symbols for /usr/local/lib/libexecinfo.so.1
Reading symbols from /usr/lib/libstdc++.so.6...done.
Loaded symbols for /usr/lib/libstdc++.so.6
Reading symbols from /lib/libm.so.5...done.
Loaded symbols for /lib/libm.so.5
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/libc.so.7...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x00000008016d52e4 in getframeaddr () from /usr/local/lib/libexecinfo.so.1
[New Thread 801f021c0 (LWP 100350)]
(gdb) bt
#0  0x00000008016d52e4 in getframeaddr () from /usr/local/lib/libexecinfo.so.1
#1  0x00000008016cee8e in backtrace () from /usr/local/lib/libexecinfo.so.1
#2  0x0000000000609dad in get_trace (skip=2, max_depth=Variable "max_depth" is not available.) at vm/exception.cpp:55
#3  0x000000000060adf4 in get_cpp_backtrace () at vm/exception.cpp:140
#4  0x000000000060aff5 in VMException (this=0x8041f41f0, reason=0x0, make_backtrace=Variable "make_backtrace" is not available.) at vm/exception.cpp:155
#5  0x000000000060b04e in rubinius::TypeError::raise (type=rubinius::ClassType, obj=0x801f0c280, reason=0x0) at exception.hpp:86
#6  0x0000000000810c5a in TestException::test_type_error_raise (this=0x14b9140) at test_exception.hpp:29
#7  0x0000000000810d28 in TestDescription_TestException_test_type_error_raise::runTest (this=0x14b94c0) at vm/test/runner.cpp:1367
#8  0x0000000000778c91 in CxxTest::RealTestDescription::run (this=0x14b94c0) at RealDescriptions.cpp:96
#9  0x000000000088db1e in CxxTest::TestRunner::runTest (this=0x7fffffffe777, td=@0x14b94c0) at TestRunner.h:86
#10 0x000000000088dc92 in CxxTest::TestRunner::runSuite (this=0x7fffffffe777, sd=@0x14b24c0) at TestRunner.h:71
#11 0x000000000088de01 in CxxTest::TestRunner::runWorld (this=0x7fffffffe777) at TestRunner.h:50
#12 0x000000000088dec7 in CxxTest::TestRunner::runAllTests (listener=@0x7fffffffe7c0) at TestRunner.h:23
#13 0x000000000088df55 in CxxTest::ErrorFormatter::run (this=0x7fffffffe7c0) at ErrorFormatter.h:49
#14 0x0000000000778e30 in main () at vm/test/runner.cpp:20
(gdb) q

I looked into libexecinfo but can't find anything suspicious. Maybe the __builtin_return_address and/or __builtin_frame_address functions are broken on FreeBSD.

@rue

This comment has been minimized.

Show comment
Hide comment
@rue

rue Apr 25, 2010

Member

Which version of libexecinfo do you have? It used to be that libexecinfo had to be separately installed for the BSDs, not sure if that is still the case?

Member

rue commented Apr 25, 2010

Which version of libexecinfo do you have? It used to be that libexecinfo had to be separately installed for the BSDs, not sure if that is still the case?

@marius

This comment has been minimized.

Show comment
Hide comment
@marius

marius Apr 25, 2010

Contributor

Yes, this is still the case. I think I found the culprit, it seems like FreeBSD/amd64 is omitting the frame-pointer by default in higher -O levels. When I use the following patch it seems to work fine:
diff --git a/rakelib/vm.rake b/rakelib/vm.rake
index c16c66a..a05dbd6 100644
--- a/rakelib/vm.rake
+++ b/rakelib/vm.rake
@@ -149,7 +149,7 @@ end
INCLUDES.map! { |f| "-I#{f}" }

 # Default build options
-BASIC_FLAGS     = %W[ -pipe -Wall -Wno-deprecated ]
+BASIC_FLAGS     = %W[ -pipe -Wall -Wno-deprecated -fno-omit-frame-pointer]

 FLAGS = BASIC_FLAGS.dup

@@ -231,8 +231,7 @@ end
 def ld(t)
   link_opts = llvm_link_flags()

-  link_opts += ' -Wl,--export-dynamic' if RUBY_PLATFORM =~ /linux/i
-  link_opts += ' -rdynamic'            if RUBY_PLATFORM =~ /bsd/
+  link_opts += ' -Wl,--export-dynamic' if RUBY_PLATFORM =~ /linux|bsd/i

   # Include LDFLAGS
   if str = ENV['LDFLAGS']

But that should probably be only for platform bsd.

Contributor

marius commented Apr 25, 2010

Yes, this is still the case. I think I found the culprit, it seems like FreeBSD/amd64 is omitting the frame-pointer by default in higher -O levels. When I use the following patch it seems to work fine:
diff --git a/rakelib/vm.rake b/rakelib/vm.rake
index c16c66a..a05dbd6 100644
--- a/rakelib/vm.rake
+++ b/rakelib/vm.rake
@@ -149,7 +149,7 @@ end
INCLUDES.map! { |f| "-I#{f}" }

 # Default build options
-BASIC_FLAGS     = %W[ -pipe -Wall -Wno-deprecated ]
+BASIC_FLAGS     = %W[ -pipe -Wall -Wno-deprecated -fno-omit-frame-pointer]

 FLAGS = BASIC_FLAGS.dup

@@ -231,8 +231,7 @@ end
 def ld(t)
   link_opts = llvm_link_flags()

-  link_opts += ' -Wl,--export-dynamic' if RUBY_PLATFORM =~ /linux/i
-  link_opts += ' -rdynamic'            if RUBY_PLATFORM =~ /bsd/
+  link_opts += ' -Wl,--export-dynamic' if RUBY_PLATFORM =~ /linux|bsd/i

   # Include LDFLAGS
   if str = ENV['LDFLAGS']

But that should probably be only for platform bsd.

@evanphx

This comment has been minimized.

Show comment
Hide comment
@evanphx

evanphx May 5, 2010

Member

Seems like your libexecinfo is broken. I've just commited a configure change so you can do --without-execinfo to disable it all together. Please try that.

Member

evanphx commented May 5, 2010

Seems like your libexecinfo is broken. I've just commited a configure change so you can do --without-execinfo to disable it all together. Please try that.

@marius

This comment has been minimized.

Show comment
Hide comment
@marius

marius May 10, 2010

Contributor

It's working when I do a ./configure --without-execinfo. However I think I can not get any backtraces then. As I wrote I can get everything to run when I add -fno-omit-frame-pointer, even backtraces. Maybe there are more platforms which strip frame-pointers by default, these should be broken too right now with regards to execinfo.

Contributor

marius commented May 10, 2010

It's working when I do a ./configure --without-execinfo. However I think I can not get any backtraces then. As I wrote I can get everything to run when I add -fno-omit-frame-pointer, even backtraces. Maybe there are more platforms which strip frame-pointers by default, these should be broken too right now with regards to execinfo.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment