Issue #18050 has been updated by sydofficious (Kenneth Dunlap).


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) $@

----------------------------------------
Bug #18050: Cannot build ruby-2.7.4 on NetBSD
https://bugs.ruby-lang.org/issues/18050#change-93045

* Author: sydofficious (Kenneth Dunlap)
* Status: Open
* Priority: Normal
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
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 2.7.4

   * 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. -L/usr/local/lib -fstack-protector-strong\
                          -Wl,-export-dynamic
   * DLDFLAGS:            -L. -L/usr/local/lib\
                          -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
   * install doc:         no
   * JIT support:         yes
   * man page type:       man
   * BASERUBY -v:         ruby 2.7.3p183 (2021-04-05 revision 6847ee089d)\
                          [x86_64-netbsd9.1]


In this case, make made it to here:
generating encdb.h
encdb.h updated
-e:1: [BUG] Segmentation fault
ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [x86_64-netbsd9.1]

-- Control frame information -----------------------------------------------
c:0004 p:---- s:0015 e:000014 CFUNC  :gets
c:0003 p:---- s:0012 e:000011 CFUNC  :gets
c:0002 p:0102 s:0008 E:000750 EVAL   -e:1 [FINISH]
c:0001 p:0000 s:0003 E:001d70 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
-e:1:in `<main>'
-e:1:in `gets'
-e:1:in `gets'

-- C level backtrace information -------------------------------------------
/usr/local/lib/libruby.so.27(rb_profile_frame_full_label+0x19) [0x79121c4bc4b7]
/usr/local/lib/libruby.so.27(rb_profile_frame_full_label+0x7c) [0x79121c4bc54a]
/usr/local/lib/libruby.so.27(rb_bug+0x124) [0x79121c2bca75]
/usr/local/lib/libruby.so.27(ruby_posix_signal+0x0) [0x79121c40ef41]
/usr/lib/libc.so.12(__sigtramp_siginfo_2+0x0) [0x79121a0a1d50]

-- Other runtime information -----------------------------------------------

* Loaded script: -e

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 rational.so
    3 complex.so
    4 ruby2_keywords.rb
    5 /usr/local/lib/ruby/2.7.0/x86_64-netbsd9.1/enc/encdb.so
    6 /usr/local/lib/ruby/2.7.0/x86_64-netbsd9.1/enc/trans/transdb.so

gmake: *** [Makefile:1489: .rbconfig.time] Abort trap (core dumped)

Again, it seems pretty random.  First attempt, it didn't segfault until the make install phase.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>