Bug #18049
closedCannot build ruby-3.0.2 on NetBSD
Description
I get random segfaults when attempting to build on NetBSD
uname -a
NetBSD juggler.panix.com 9.1 NetBSD 9.1 (PANIX-STD) #2: Thu Mar 18 17:46:23 EDT 2021 root@juggler.panix.com:/misc/obj64/misc/devel/netbsd/9.1/src/sys/arch/amd64/compile/PANIX-STD amd64
Configuration summary for ruby version 3.0.2
* Installation prefix: /usr/local
* exec prefix: ${prefix}
* arch: x86_64-netbsd9.1
* site arch: ${arch}
* RUBY_BASE_NAME: ruby
* enable shared: yes
* ruby lib prefix: ${libdir}/${RUBY_BASE_NAME}
* site libraries path: ${rubylibprefix}/${sitearch}
* vendor path: ${rubylibprefix}/vendor_ruby
* target OS: netbsd9.1
* compiler: gcc
* with pthread: yes
* with coroutine: ucontext
* enable shared libs: yes
* dynamic library ext: so
* CFLAGS: ${optflags} ${debugflags} ${warnflags}
* LDFLAGS: -L. -fstack-protector-strong -Wl,-export-dynamic
* DLDFLAGS: -Wl,--compress-debug-sections=zlib
* optflags: -O3
* debugflags: -ggdb3
* warnflags: -Wall -Wextra -Wdeprecated-declarations\
-Wduplicated-cond -Wimplicit-function-declaration\
-Wimplicit-int -Wmisleading-indentation\
-Wpointer-arith -Wwrite-strings\
-Wimplicit-fallthrough=0 -Wmissing-noreturn\
-Wno-cast-function-type\
-Wno-constant-logical-operand -Wno-long-long\
-Wno-missing-field-initializers\
-Wno-overlength-strings\
-Wno-packed-bitfield-compat\
-Wno-parentheses-equality -Wno-self-assign\
-Wno-tautological-compare -Wno-unused-parameter\
-Wno-unused-value -Wsuggest-attribute=format\
-Wsuggest-attribute=noreturn -Wunused-variable
* strip command: strip -S -x
* install doc: no
* JIT support: yes
* man page type: man
* BASERUBY -v: ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38)\
[x86_64-netbsd9.1]
BASERUBY = /usr/local/bin/ruby --disable=gems
CC = gcc
LD = ld
LDSHARED = gcc -shared
CFLAGS = -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -std=gnu99 -fPIC -pipe
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -fvisibility=hidden -fexcess-precision=standard -DRUBY_EXPORT -I. -I.ext/include/x86_64-netbsd9.1 -I./include -I. -I./enc/unicode/12.1.0
CPPFLAGS =
DLDFLAGS = -Wl,--compress-debug-sections=zlib -Wl,-soname,liblibruby30.so.30 -fstack-protector-strong
SOLIBS = -lexecinfo -lz -lpthread -lrt -lrt -lcrypt -lm
LANG = en_US.UTF-8
LC_ALL =
LC_CTYPE =
MFLAGS =
gcc (nb4 20200810) 7.5.0
This particular time, it segfaulted here:
making prelude.rbinc
/usr/local/lib/ruby/3.0.0/ripper/lexer.rb:70: [BUG] Segmentation fault
ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-netbsd9.1]
-- Control frame information -----------------------------------------------
c:0009 p:---- s:0037 e:000036 CFUNC :new
c:0008 p:0043 s:0028 e:000027 CLASS /usr/local/lib/ruby/3.0.0/ripper/lexer.rb:70
c:0007 p:0042 s:0025 e:000024 CLASS /usr/local/lib/ruby/3.0.0/ripper/lexer.rb:55
c:0006 p:0013 s:0022 e:000021 TOP /usr/local/lib/ruby/3.0.0/ripper/lexer.rb:14 [FINISH]
c:0005 p:---- s:0019 e:000018 CFUNC :require
c:0004 p:0011 s:0014 e:000013 TOP /usr/local/lib/ruby/3.0.0/ripper.rb:3 [FINISH]
c:0003 p:---- s:0011 e:000010 CFUNC :require
c:0002 p:0005 s:0006 e:000005 EVAL ./tool/mk_builtin_loader.rb:3 [FINISH]
c:0001 p:0000 s:0003 E:001d70 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
./tool/mk_builtin_loader.rb:3:in `<main>'
./tool/mk_builtin_loader.rb:3:in `require'
/usr/local/lib/ruby/3.0.0/ripper.rb:3:in `<top (required)>'
/usr/local/lib/ruby/3.0.0/ripper.rb:3:in `require'
/usr/local/lib/ruby/3.0.0/ripper/lexer.rb:14:in `<top (required)>'
/usr/local/lib/ruby/3.0.0/ripper/lexer.rb:55:in `<class:Ripper>'
/usr/local/lib/ruby/3.0.0/ripper/lexer.rb:70:in `<class:Lexer>'
/usr/local/lib/ruby/3.0.0/ripper/lexer.rb:70:in `new'
-- C level backtrace information -------------------------------------------
/usr/local/lib/libruby.so.30(rb_profile_frame_full_label+0x19) [0x79baa3ee2399]
/usr/local/lib/libruby.so.30(rb_profile_frame_full_label+0x8e) [0x79baa3ee243e]
/usr/local/lib/libruby.so.30(rb_bug+0x124) [0x79baa3cc3211]
/usr/local/lib/libruby.so.30(ruby_posix_signal+0x0) [0x79baa3e2eb49]
/usr/lib/libc.so.12(__sigtramp_siginfo_2+0x0) [0x79baa1aa1d50]
-- Other runtime information -----------------------------------------------
* Loaded script: ./tool/mk_builtin_loader.rb
* Loaded features:
0 enumerator.so
1 thread.rb
2 rational.so
3 complex.so
4 ruby2_keywords.rb
5 /usr/local/lib/ruby/3.0.0/x86_64-netbsd9.1/enc/encdb.so
6 /usr/local/lib/ruby/3.0.0/x86_64-netbsd9.1/enc/trans/transdb.so
7 /usr/local/lib/ruby/3.0.0/x86_64-netbsd9.1/ripper.so
8 /usr/local/lib/ruby/3.0.0/ripper/core.rb
gmake: *** [Makefile:1833: prelude.rbinc] Abort trap (core dumped)
Other times it will segfault in other places. It seems pretty random.
Updated by xtkoba (Tee KOBAYASHI) over 2 years ago
First, it should be clarified that it is the already installed /usr/local/bin/ruby
(version 3.0.1p64) that segfaults here.
I guess that the source comes directly from a Git repository, as prelude.rbinc
should be prebuilt in a release tarball which should be tried out for self-containedness.
To avoid using already installed Ruby interpreters try adding the option --with-baseruby=no
to ./configure
.
Updated by sydofficious (Kenneth Dunlap) over 2 years ago
This turned out to be an issue with miniruby when the NetBSD kernel has PaX ASLR (Address Space Layout Randomization) enabled. The following patch, applied post-configure, works around the problem.
--- Makefile.orig 2021-07-28 13:31:38.018160281 -0400
+++ Makefile 2021-07-28 13:37:35.292884198 -0400
@@ -270,6 +270,7 @@
$(ECHO) linking $@
$(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(MAINLIBS) $(LIBS) $(OUTFLAG)$@
$(Q) $(POSTLINK)
+ paxctl +a $@
$(PROGRAM):
@$(RM) $@
Updated by nobu (Nobuyoshi Nakada) over 2 years ago
- Has duplicate Bug #18050: Cannot build ruby-2.7.4 on NetBSD added
Updated by nobu (Nobuyoshi Nakada) over 2 years ago
Does this work?
diff --git a/configure.ac b/configure.ac
index d018e8a6f4f..2d91972c218 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1176,6 +1176,10 @@ main()
ac_cv_func_close=no
],
[netbsd*], [ LIBS="-lm $LIBS"
+ AC_CHECK_PROGS(paxctl, paxctl)
+ AS_IF([test -n "$paxctl"], [
+ POSTLINK="$paxctl +a\$@${POSTLINK:+; $POSTLINK}"
+ ])
],
[dragonfly*], [ LIBS="-lm $LIBS"
],
Updated by nobu (Nobuyoshi Nakada) over 2 years ago
Maybe only miniruby needs to disable ASLR?
Updated by nobu (Nobuyoshi Nakada) over 2 years ago
- Status changed from Open to Feedback