Bug #15091
closed[solaris] encdb.h.tmpl segfault
Description
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/gcc/7/lib/gcc/x86_64-pc-solaris2.11/7.3.0/lto-wrapper
Target: x86_64-pc-solaris2.11
Configured with: /builds/ulhg/workspace/Solaris_11u4/Userland/full-build/02a-build-i386/components/gcc7/gcc-7.3.0/configure --prefix=/usr/gcc/7 --mandir=/usr/gcc/7/share/man --bindir=/usr/gcc/7/bin --sbindir=/usr/gcc/7/sbin --libdir=/usr/gcc/7/lib --infodir=/usr/gcc/7/share/info --libexecdir=/usr/gcc/7/lib --enable-languages=c,c++,fortran,objc --enable-shared --enable-initfini-array --disable-rpath --with-system-zlib --with-build-config=no --with-gmp-include=/usr/include --with-mpfr-include=/usr/include --without-gnu-ld --with-ld=/usr/bin/ld --with-gnu-as --with-as=/usr/gnu/bin/as --disable-bootstrap 'BOOT_CFLAGS=-g -O2' x86_64-pc-solaris2.11
Thread model: posix
gcc version 7.3.0 (GCC)
ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [amd64-solaris2.11]
uname -a
SunOS 5.11 11.4.0.15.0 i86pc i386 i86pc
https://www.oracle.com/technetwork/server-storage/solaris11/downloads/index.html
make
generating encdb.h
./template/encdb.h.tmpl:36: [BUG] Segmentation fault at 0x00000000403264b0
ruby 2.6.0dev (2018-09-08) [x86_64-solaris2.11]
-- Control frame information -----------------------------------------------
c:0011 p:---- s:0066 e:000065 CFUNC :sort_by
c:0010 p:0034 s:0062 e:000061 BLOCK ./template/encdb.h.tmpl:36 [FINISH]
c:0009 p:---- s:0058 e:000057 CFUNC :each
c:0008 p:0090 s:0054 E:0017f0 EVAL ./template/encdb.h.tmpl:34 [FINISH]
c:0007 p:---- s:0043 e:000042 CFUNC :eval
c:0006 p:0041 s:0035 e:000034 METHOD /root/ruby/lib/erb.rb:892
c:0005 p:0010 s:0030 E:0020e0 BLOCK ./tool/generic_erb.rb:42
c:0004 p:0104 s:0027 E:001810 BLOCK ./tool/generic_erb.rb:42 [FINISH]
c:0003 p:---- s:0022 e:000021 CFUNC :map
c:0002 p:0128 s:0018 E:0006b0 EVAL ./tool/generic_erb.rb:35 [FINISH]
c:0001 p:0000 s:0003 E:001060 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
./tool/generic_erb.rb:35:in `<main>'
./tool/generic_erb.rb:35:in `map'
./tool/generic_erb.rb:42:in `block in <main>'
./tool/generic_erb.rb:42:in `block (2 levels) in <main>'
/root/ruby/lib/erb.rb:892:in `result'
/root/ruby/lib/erb.rb:892:in `eval'
./template/encdb.h.tmpl:34:in `block (2 levels) in <main>'
./template/encdb.h.tmpl:34:in `each'
./template/encdb.h.tmpl:36:in `block (3 levels) in <main>'
./template/encdb.h.tmpl:36:in `sort_by'
I can reproduce the problem on master ( https://github.com/ruby/ruby/commit/7671126dfb38255d7dbb74d3a5e40520ca94158b ) and ruby 2.5.2
Files
Updated by ahorek (Pavel Rosický) almost 6 years ago
- File 25_log.txt 25_log.txt added
- File 26_log.txt 26_log.txt added
Updated by normalperson (Eric Wong) almost 6 years ago
pdahorek@seznam.cz wrote:
https://bugs.ruby-lang.org/issues/15091
https://www.oracle.com/technetwork/server-storage/solaris11/downloads/index.html
Weird, I'm not familiar with Solaris versions, but it seems our
CI machines are not affected
http://rubyci.s3.amazonaws.com/unstable11x/ruby-trunk/log/20180908T202406Z.log.html.gz
http://rubyci.s3.amazonaws.com/unstable11s/ruby-trunk/log/20180908T202505Z.log.html.gz
./template/encdb.h.tmpl:36: [BUG] Segmentation fault at 0x00000000403264b0
ruby 2.6.0dev (2018-09-08) [x86_64-solaris2.11]-- Control frame information -----------------------------------------------
c:0011 p:---- s:0066 e:000065 CFUNC :sort_by
c:0010 p:0034 s:0062 e:000061 BLOCK ./template/encdb.h.tmpl:36 [FINISH]
c:0009 p:---- s:0058 e:000057 CFUNC :each
Likely culprit is qsort_s being detected on your system (but not our CI machines):
checking for qsort_r... no
checking for qsort_s... yes
Leading to this:
compiling util.c
util.c: In function ?ruby_qsort?:
util.c:200:24: warning: passing argument 4 of ?qsort_s? from incompatible pointer type [-Wincompatible-pointer-types]define cmp_bsd_qsort cmp_ms_qsort¶
^
util.c:199:70: note: in definition of macro ?qsort_r?
define qsort_r(base, nel, size, arg, cmp) qsort_s(base, nel, size, cmp, arg)¶
^~~
util.c:224:37: note: in expansion of macro ?cmp_bsd_qsort?
qsort_r(base, nel, size, &args, cmp_bsd_qsort);
^~~~~~~~~~~~~
In file included from /usr/include/stdlib.h:12:0,
from ./include/ruby/defines.h:121,
from ./include/ruby/ruby.h:29,
from ./include/ruby.h:33,
from internal.h:15,
from util.c:16:
/usr/include/iso/stdlib_iso.h:147:16: note: expected ?int (*)(const void *, const void *, void )? but argument is of type ?int ()(void *, const void *, const void *)?
extern errno_t qsort_s(void *, rsize_t, rsize_t,
^~~~~~~
util.c: At top level:
cc1: warning: unrecognized command line option ?-Wno-cast-function-type?
cc1: warning: unrecognized command line option ?-Wno-self-assign?
cc1: warning: unrecognized command line option ?-Wno-constant-logical-operand?
cc1: warning: unrecognized command line option ?-Wno-parentheses-equality?
So, yes, it would crash if function signatures are wrong.
Somebody with access to Solaris should be able to fix this
easily.
Updated by nobu (Nobuyoshi Nakada) almost 6 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r64661.
util.c: qsort_s in C11
-
configure.ac: macro for C11 to use qsort_s.
-
util.c (ruby_qsort): fix for C11 qsort_s. the comparison function
for MSVCRT qsort_s is compatible with BSD qsort_r, but not with C11
qsort_s, in spite of its name.
note that mingw defines STDC_VERSION but uses qsort_s in MSVCRT,
so the MSVCRT block needs to preced the C11 block.
[ruby-core:88899] [Bug #15091]
Updated by ahorek (Pavel Rosický) almost 6 years ago
thanks @nobu (Nobuyoshi Nakada)
but now I have an error
error Unknown version qsort_s
the build passed without this line
https://github.com/ruby/ruby/commit/8e9a8c043ef5b16a2f13999bd2c5d59d61dd00d1#diff-6d7e72ea1ca2b7d0258e568a155084bdR219