Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 561780

Summary: dev-lang/ruby-2.1.6-r1 - src_compile(): segmentation fault in: ./miniruby -I./lib -I. -I.ext/common ./tool/mkconfig.rb -timestamp=.rbconfig.time -install_name=ruby21 -so_name=ruby21 rbconfig.rb
Product: Gentoo Linux Reporter: Émeric Maschino <emeric.maschino>
Component: Current packagesAssignee: Gentoo Ruby Team <ruby>
Status: RESOLVED FIXED    
Severity: normal CC: emeric.maschino, ia64, slyfox
Priority: Normal Keywords: PATCH, REGRESSION
Version: unspecified   
Hardware: IA64   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=539054
https://bugs.gentoo.org/show_bug.cgi?id=513888
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: build.log
environment
backtrace
backtrace against 2.4.0
ruby-2.1.9-ia64.patch

Description Émeric Maschino 2015-09-29 06:17:28 UTC
Created attachment 413234 [details]
build.log

Hi,

While attempting emerge @world, Ruby 2.1 failed to build on my ia64 workstation. Bug 539054 reports the same issue, but against Ruby 2.0 and on ARM hardware, so I don't know how it can relate and whether this one is a duplicate or a totally different issue.

Setting back Ruby 1.9 as default interpreter during build didn't help (I don't know if current Ruby interpreter is involved during build of a newest Ruby version). 

Dropping --as-needed from LDFLAGS (as it's a known issue with some packages on ia64) didn't help either.

Ruby 1.9 was the last working version on ia64 (Ruby 2.0 fails to build WebKit-GTK: bug #513888).

     Émeric
Comment 1 Émeric Maschino 2015-09-29 06:18:11 UTC
Created attachment 413236 [details]
environment
Comment 2 Émeric Maschino 2015-09-29 06:22:00 UTC
emerge --info output:

Portage 2.2.20.1 (python 3.4.1-final-0, default/linux/ia64/13.0/desktop/gnome/systemd, gcc-4.7.4, glibc-2.20-r2, 4.0.5-gentoo ia64)
=================================================================
System uname: Linux-4.0.5-gentoo-ia64-Madison-with-gentoo-2.2
KiB Mem:    25052480 total,  17582464 free
KiB Swap:     524224 total,    524224 free
Timestamp of repository gentoo: Mon, 28 Sep 2015 20:30:01 +0000
sh bash 4.3_p39
ld GNU ld (Gentoo 2.25.1 p1.1) 2.25.1
app-shells/bash:          4.3_p39::gentoo
dev-lang/perl:            5.20.2::gentoo
dev-lang/python:          2.7.9-r1::gentoo, 3.4.1::gentoo
dev-util/cmake:           2.8.12.2-r1::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/openrc:          0.17::gentoo
sys-apps/sandbox:         2.6-r1::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69::gentoo
sys-devel/automake:       1.11.6-r1::gentoo, 1.15::gentoo
sys-devel/binutils:       2.25.1-r1::gentoo
sys-devel/gcc:            4.5.4::gentoo, 4.6.4::gentoo, 4.7.4::gentoo
sys-devel/gcc-config:     1.7.3::gentoo
sys-devel/libtool:        2.4.6::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 3.18::gentoo (virtual/os-headers)
sys-libs/glibc:           2.20-r2::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000

my_ebuilds
    location: /var/lib/layman/my_ebuilds
    masters: gentoo
    priority: 0

ACCEPT_KEYWORDS="ia64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="ia64-unknown-linux-gnu"
CFLAGS="-O2 -pipe -mtune=itanium2"
CHOST="ia64-unknown-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -mtune=itanium2"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe -mtune=itanium2"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-O2 -pipe -mtune=itanium2"
GENTOO_MIRRORS="ftp://mirrors.linuxant.fr/distfiles.gentoo.org/"
LANG="fr_FR.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac acl acpi alsa berkdb branding bzip2 cairo cdda cdr cli colord cracklib crypt cups cxx dbus dri dts dvdr eds encode evo exif fam firefox flac fortran gdbm gif glamor gnome gnome-keyring gnome-online-accounts gpm gstreamer gtk ia64 iconv introspection ipv6 jpeg lcms ldap libnotify libsecret mad mng modules mp3 mp4 mpeg nautilus ncurses nls nptl ogg opengl openmp pam pango pcre pdf png policykit ppds pulseaudio qt3support qt4 readline sdl session spell ssl startup-notification svg systemd tcpd tiff tracker truetype udev udisks unicode upower usb vorbis wxwidgets xcb xml xv xvid zlib" ALSA_CARDS="fm801" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="fr" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby20 ruby21" USERLAND="GNU" VIDEO_CARDS="fbdev modesetting radeon" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 3 Émeric Maschino 2015-09-29 06:22:39 UTC
emerge -pqv output:

[ebuild  NS   ] dev-lang/ruby-2.1.6-r1 [1.9.3_p551-r1, 2.0.0_p645] USE="berkdb gdbm ipv6 ncurses rdoc readline ssl -debug -doc -examples -rubytests -socks5 (-xemacs)" 
[ebuild   R   ] dev-ruby/rubygems-2.2.5-r1  USE="-server {-test}" RUBY_TARGETS="ruby20 ruby21* -ruby19*" 
[ebuild   R   ] virtual/rubygems-10  RUBY_TARGETS="ruby20 ruby21* -ruby19*" 
[ebuild   R   ] dev-ruby/rake-0.9.6-r1  USE="-doc {-test}" RUBY_TARGETS="ruby20 ruby21* -ruby19*" 
[ebuild   R   ] dev-ruby/json-1.8.2-r1  USE="-doc {-test}" RUBY_TARGETS="ruby20 ruby21* -ruby19*" 
[ebuild   R   ] dev-ruby/racc-1.4.11  USE="-doc {-test}" RUBY_TARGETS="ruby20 ruby21* -ruby19*" 
[ebuild   R   ] dev-ruby/rdoc-4.0.1-r2  USE="-doc {-test}" RUBY_TARGETS="ruby20 ruby21* -ruby19*"
Comment 4 Hans de Graaff gentoo-dev Security 2015-10-11 10:03:36 UTC
I'm afraid there is not much I can do about this bug. I've cc'ed the ia64 team, perhaps they have some additional insight. This version has been marked stable by them so I assume this is not a structural ia64 problem, but I'm not sure if some variation in ia64 architecture may cause this.
Comment 5 Émeric Maschino 2016-11-17 00:30:32 UTC
(In reply to Hans de Graaff from comment #4)
> I'm afraid there is not much I can do about this bug. I've cc'ed the ia64
> team, perhaps they have some additional insight. This version has been
> marked stable by them so I assume this is not a structural ia64 problem, but
> I'm not sure if some variation in ia64 architecture may cause this.

=dev-lang/ruby-2.1.9 is still failing the same. In fact, the produced miniruby crashes on itself, no need to pass complex arguments to miniruby on the command-line. Here's the backtrace I get when simply running the generated miniruby from gdb:

Starting program: /var/tmp/portage/dev-lang/ruby-2.1.9/work/ruby-2.1.9/miniruby 
Failed to read a valid object file image from memory.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
mark_locations_array (n=<optimized out>, x=0x0, objspace=0x6000000000039db0) at gc.c:3298
3298		gc_mark_maybe(objspace, v);

Thread 1 (Thread 0x2000000000043bd0 (LWP 31411)):
#0  mark_locations_array (n=<optimized out>, x=0x0, objspace=0x6000000000039db0) at gc.c:3298
        v = <error reading variable v (Cannot access memory at address 0x0)>
#1  gc_mark_locations (objspace=0x6000000000039db0, start=<optimized out>, end=<optimized out>) at gc.c:3310
        n = 864692227966763254
#2  0x4000000000115260 in gc_mark_locations (end=<optimized out>, start=<optimized out>, objspace=0x6000000000039db0) at gc.c:3506
No locals.
#3  mark_current_machine_context (objspace=0x6000000000039db0, th=0x60000000000395b0) at gc.c:3500
        save_regs_gc_mark = {j = {{__jmpbuf = {6917546619827102000, 4611686018428523616, 6917546619827101984, 6917537823734106032, 0, -4611686018427377323, 0 <repeats 29 times>, 2637824, 2632412, 2632412, 0, 5, 2686976, 2719744, 2718696, 2734136, 2621440, 3, 0 <repeats 13 times>, 868352, 867880, 867880, 0, 5, 917504, 950272, 935448, 935504, 6917546619827102600, 6917546619827102592}, __mask_was_saved = 266136, __saved_mask = {__val = {6917546619827102592, 6917546619827102600, 309920, 0, 0, 1, 98304, 1, 0, 1, 3, 0, 917504, 912424, 912424, 0}}}}, v = {6917546619827102000, 4611686018428523616, 6917546619827101984, 6917537823734106032, 0, 13835058055282174293, 0 <repeats 29 times>, 2637824, 2632412, 2632412, 0, 5, 2686976, 2719744, 2718696, 2734136, 2621440, 3, 0 <repeats 13 times>, 868352, 867880, 867880, 0, 5, 917504, 950272, 935448, 935504, 6917546619827102600, 6917546619827102592, 2305843009213960088, 6917546619827102592, 6917546619827102600, 309920, 0, 0, 1, 98304, 1, 0, 1, 3, 0, 917504, 912424, 912424, 0, 5}}
        stack_start = 0x60000fffffffa120
        stack_end = 0x60000fffffffc000
#4  0x4000000000117ff0 in gc_mark_roots (categoryp=0x0, full_mark=0, objspace=0x6000000000039db0) at gc.c:4105
        list = <optimized out>
        th = 0x60000000000395b0
#5  gc_marks_body (objspace=0x6000000000039db0, full_mark=0) at gc.c:4164
No locals.
#6  0x400000000011a670 in gc_marks (full_mark=<optimized out>, objspace=0x6000000000039db0) at gc.c:4526
        prev_mark_func_data = 0x0
#7  garbage_collect_body (objspace=0x6000000000039db0, full_mark=<optimized out>, immediate_sweep=<optimized out>, reason=<optimized out>) at gc.c:5024
No locals.
#8  0x400000000011bba0 in heap_prepare_freepage (heap=0x6000000000039dc0, objspace=0x6000000000039db0) at gc.c:1219
No locals.
#9  heap_get_freeobj_from_next_freepage (heap=<optimized out>, objspace=0x6000000000039db0) at gc.c:1237
        page = 0x0
        p = <optimized out>
#10 heap_get_freeobj (heap=0x6000000000039dc0, objspace=0x6000000000039db0) at gc.c:1259
        p = 0x0
#11 newobj_of (klass=0, flags=40, v1=0, v2=0, v3=0) at gc.c:1303
        objspace = 0x6000000000039db0
#12 0x40000000001264b0 in hash_alloc (klass=0) at hash.c:289
        hash = <optimized out>
#13 0x40000000003c1120 in Init_BareVM () at vm.c:2822
        vm = 0x6000000000038f20
        th = 0x60000000000395b0
#14 0x40000000000d25c0 in ruby_setup () at eval.c:54
        initialized = 1
        state = 4902400
#15 0x40000000000d68a0 in ruby_init () at eval.c:75
        state = <optimized out>
#16 0x400000000001d6f0 in main (argc=1, argv=0x60000fffffffad88) at main.c:35
        variable_in_this_stack_frame = 0


Anything else I can do to help fix this error? There's currently no working Ruby on ia64 :-(

     Émeric
Comment 6 Agostino Sarubbo gentoo-dev 2017-01-24 13:08:04 UTC
I see this bug right now also here. Can we report it to upstream?
Comment 7 Agostino Sarubbo gentoo-dev 2017-01-24 13:13:18 UTC
Created attachment 461244 [details]
backtrace

Putting the backtrace as attachment.
Comment 8 Émeric Maschino 2017-01-24 14:20:24 UTC
(In reply to Agostino Sarubbo from comment #6)
> I see this bug right now also here. Can we report it to upstream?

Still on ia64 or yet another arch, such as ARM as in bug #539054?

     Émeric
Comment 9 Hans de Graaff gentoo-dev Security 2017-01-24 18:49:54 UTC
(In reply to Agostino Sarubbo from comment #6)
> I see this bug right now also here. Can we report it to upstream?

Ruby 2.1 is currently in security-patches-only mode and be EOL in a few weeks. Bug reports filed against ruby 2.4 probably have the best chance of being addressed upstream (and may then be backported to 2.3 and 2.2 when possible).
Comment 10 Agostino Sarubbo gentoo-dev 2017-01-26 10:32:35 UTC
(In reply to Émeric Maschino from comment #8)
> Still on ia64 or yet another arch, such as ARM as in bug #539054?
ia64



(In reply to Hans de Graaff from comment #9)
> Ruby 2.1 is currently in security-patches-only mode and be EOL in a few
> weeks. Bug reports filed against ruby 2.4 probably have the best chance of
> being addressed upstream (and may then be backported to 2.3 and 2.2 when
> possible).

I'm testing the newer versions right now.
Comment 11 Agostino Sarubbo gentoo-dev 2017-01-26 11:08:25 UTC
Created attachment 461500 [details]
backtrace against 2.4.0

miniruby on 2.4.0 does not crash if called without arguments or with --help (2.1 does)

Do you need something else?
Comment 12 Sergei Trofimovich (RETIRED) gentoo-dev 2017-05-20 14:16:04 UTC
Created attachment 473466 [details, diff]
ruby-2.1.9-ia64.patch

ruby has explicit support for ia64 stack scavenging in garbage collector.

On host architectures thread has only a pair of addresses to descripe a stack:
stack_start/stack_end.

is64 is specific in that it has two pairs: stack_start/stack_end and register_stack_start/register_stack_end

Both are supposed to be initialized in ruby_init_stack().

Except once case when glibc is new enough. In this case MAINSTACKADDR_AVAILABLE
is defined and ruby_init_stack() exist early and misses register_stack_start
initialization.

The fix [attached] happens to be trivial: initialize register_stack_start
before stack_start.

ruby-2.1.9-ia64.patch is noninvasive:
- it moves around code under __ia64
- it applies on ruby-2.1.9 and 2.4.1 ebuilds

I tested 2.1.9 and 2.4.1 on ia64. Both seem to work. I'll send the patch upstream as well.
Comment 13 Sergei Trofimovich (RETIRED) gentoo-dev 2017-05-20 14:53:29 UTC
> I tested 2.1.9 and 2.4.1 on ia64. Both seem to work. I'll send the patch
> upstream as well.

Proposed upstream as https://github.com/ruby/ruby/pull/1625
Comment 14 Sergei Trofimovich (RETIRED) gentoo-dev 2017-05-26 21:35:30 UTC
I've pushed the fix as: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fca896513471e35284c8204fae25f6620a17a2e3

I hope it won't interfere in how ruby@ does patchset management.
Comment 15 Hans de Graaff gentoo-dev Security 2017-05-27 04:59:34 UTC
(In reply to Sergei Trofimovich from comment #14)
> I've pushed the fix as:
> https://gitweb.gentoo.org/repo/gentoo.git/commit/
> ?id=fca896513471e35284c8204fae25f6620a17a2e3
> 
> I hope it won't interfere in how ruby@ does patchset management.

I've reverted this since all patches should go through the patchset.
Comment 16 Hans de Graaff gentoo-dev Security 2017-05-27 06:34:48 UTC
(In reply to Hans de Graaff from comment #15)

> I've reverted this since all patches should go through the patchset.

This patch is now included in the -r2 revisions of ruby 2.2, ruby 2.3, and ruby 2.4.  It has not been applied to ruby 2.1 because this version is being removed.
Comment 17 Émeric Maschino 2017-05-29 19:36:48 UTC
(In reply to Sergei Trofimovich from comment #12)
ies on ruby-2.1.9 and 2.4.1 ebuilds
> 
> I tested 2.1.9 and 2.4.1 on ia64. Both seem to work. I'll send the patch
> upstream as well.

Tested on 2.1.9 here too. Fixes the issue.

Thanks Sergei,

     Émeric