RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1990108 - Enable LTO build of ruby for RHEL 9
Summary: Enable LTO build of ruby for RHEL 9
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: ruby
Version: 9.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: beta
: ---
Assignee: Vít Ondruch
QA Contact: Lukáš Zachar
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-08-04 18:48 UTC by Marek Polacek
Modified: 2022-05-17 14:02 UTC (History)
5 users (show)

Fixed In Version: ruby-3.0.3-159.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-17 14:02:37 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-92384 0 None None None 2021-08-04 18:53:28 UTC

Description Marek Polacek 2021-08-04 18:48:21 UTC
During my review of LTO opt outs in RHEL9, I saw that ruby disables LTO:

    # LTO appears to cause some issue to SEGV handler.
    # https://bugs.ruby-lang.org/issues/17052
    %define _lto_cflags %{nil}

The issue is now CLOSED.  I'm not sure what happened and if it's possible to enable LTO now, so I'm opening this BZ so that we can track the status of LTO in RHEL 9.

Would it be possible for the maintainers to look into this and possibly enable LTO so that the package can benefit from smaller/faster binaries, deeper analysis for compiler warnings, etc?  If not, please feel free to CLOSED|WONTFIX.

Thanks!

Comment 2 Vít Ondruch 2021-08-05 07:28:41 UTC
This si the related fedora-devel thread discussing LTO:

https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/OAD6BEN6UMVIXAEI5EDS5COUYFSPNLZN/

And this is my last post in the thread:

https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/NLQBH6N6GK53T4CC5CM2SWQEPYGS2CMR/

Which is basically waiting for response from toolchain team.

Comment 3 Vít Ondruch 2021-08-05 07:32:43 UTC
BTW, I am surprised to have this ticket opened in RHEL9 context, while this should have been addressed in Fedora first.

Comment 4 Vít Ondruch 2021-08-05 07:52:46 UTC
I have tried to enable LTO on Fedora and this is the build:

https://koji.fedoraproject.org/koji/taskinfo?taskID=73317914

So the situation is different then it used to be. The bad news is that it crash already during compilation. The good news is that it seems that it crashed on all platforms. This is the error:

~~~
./miniruby -I./lib -I. -I.ext/common  ./tool/generic_erb.rb -c -o encdb.h ./template/encdb.h.tmpl ./enc enc
<internal:gc>:240: [BUG] Segmentation fault at 0x0000000000000004
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0003 p:0008 s:0011 e:000008 CLASS  <internal:gc>:240
c:0002 p:0015 s:0006 e:000005 TOP    <internal:gc>:235 [FINISH]
c:0001 p:0000 s:0003 E:000230 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
<internal:gc>:235:in `<internal:gc>'
<internal:gc>:240:in `<module:ObjectSpace>'
-- Machine register context ------------------------------------------------
 RIP: 0x00005585da1c832a RBP: 0x000022f100140003 RSP: 0x00007ffd6460a6a0
 RAX: 0x0000000000000001 RBX: 0x00000000000022f1 RCX: 0x00005585dade5d90
 RDX: 0x000022f100140003 RDI: 0x00005585dae0c2d8 RSI: 0x0000000000000000
  R8: 0x0000000000000000  R9: 0x00007ffd6460a6e0 R10: 0x00005585daebbe50
 R11: 0x00007f00a785baa0 R12: 0x0000000000000000 R13: 0x00005585dade5d90
 R14: 0x00005585dae0c2d8 R15: 0x00005585dade5d90 EFL: 0x0000000000010202
-- C level backtrace information -------------------------------------------
./miniruby(rb_print_backtrace+0x19) [0x5585da1cdba9]
./miniruby(rb_vm_bugreport+0x215) [0x5585da1d1a05]
./miniruby(rb_bug_for_fatal_signal+0xf4) [0x5585da004fc4]
./miniruby(sigsegv+0x4d) [0x5585da13709d]
[0x7f00a76a4760]
./miniruby(vm_ccs_push.part.0.lto_priv.0+0x2a) [0x5585da1c832a]
./miniruby(vm_search_cc+0xfe) [0x5585da1a7b7e]
./miniruby(vm_search_method_slowpath0.lto_priv.0+0x40) [0x5585da1a7d30]
./miniruby(vm_sendish.lto_priv.0+0x6e4) [0x5585da1aeff4]
./miniruby(vm_exec_core.lto_priv.0+0xa8) [0x5585da1b25b8]
./miniruby(rb_vm_exec+0x110) [0x5585da1c9ea0]
./miniruby(ruby_opt_init+0x6f) [0x5585da1355af]
./miniruby(load_file_internal+0x4b2) [0x5585da1376e2]
./miniruby(rb_ensure+0x106) [0x5585da00d5a6]
./miniruby(process_options+0x19e5) [0x5585da139a65]
./miniruby(ruby_process_options+0x151) [0x5585da13a551]
./miniruby(ruby_options+0x119) [0x5585da012de9]
./miniruby(main+0x57) [0x5585d9f8a1e7]
-- Other runtime information -----------------------------------------------
* Loaded script: ./miniruby
* Loaded features:
    0 enumerator.so
    1 thread.rb
    2 rational.so
    3 complex.so
    4 ruby2_keywords.rb
* Process memory map:
5585d9f5d000-5585d9f85000 r--p 00000000 fc:05 137001366                  /builddir/build/BUILD/ruby-3.0.2/miniruby
5585d9f85000-5585da1f2000 r-xp 00028000 fc:05 137001366                  /builddir/build/BUILD/ruby-3.0.2/miniruby
5585da1f2000-5585da2f6000 r--p 00295000 fc:05 137001366                  /builddir/build/BUILD/ruby-3.0.2/miniruby
5585da2f6000-5585da2fd000 r--p 00398000 fc:05 137001366                  /builddir/build/BUILD/ruby-3.0.2/miniruby
5585da2fd000-5585da2fe000 rw-p 0039f000 fc:05 137001366                  /builddir/build/BUILD/ruby-3.0.2/miniruby
5585da2fe000-5585da30e000 rw-p 00000000 00:00 0 
5585dad8d000-5585daed3000 rw-p 00000000 00:00 0                          [heap]
7f00a28ae000-7f00a409b000 r--s 00000000 fc:05 137001366                  /builddir/build/BUILD/ruby-3.0.2/miniruby
7f00a409b000-7f00a409e000 r--p 00000000 fc:05 270435464                  /usr/lib64/libgcc_s-11-20210728.so.1
7f00a409e000-7f00a40b0000 r-xp 00003000 fc:05 270435464                  /usr/lib64/libgcc_s-11-20210728.so.1
7f00a40b0000-7f00a40b3000 r--p 00015000 fc:05 270435464                  /usr/lib64/libgcc_s-11-20210728.so.1
7f00a40b3000-7f00a40b4000 r--p 00017000 fc:05 270435464                  /usr/lib64/libgcc_s-11-20210728.so.1
7f00a40b4000-7f00a40b5000 rw-p 00018000 fc:05 270435464                  /usr/lib64/libgcc_s-11-20210728.so.1
7f00a40b5000-7f00a40b6000 ---p 00000000 00:00 0 
7f00a40b6000-7f00a4157000 rw-p 00000000 00:00 0 
7f00a4157000-7f00a4158000 ---p 00000000 00:00 0 
7f00a4158000-7f00a41f9000 rw-p 00000000 00:00 0 
7f00a41f9000-7f00a41fa000 ---p 00000000 00:00 0 
7f00a41fa000-7f00a429b000 rw-p 00000000 00:00 0 
7f00a429b000-7f00a429c000 ---p 00000000 00:00 0 
7f00a429c000-7f00a433d000 rw-p 00000000 00:00 0 
7f00a433d000-7f00a433e000 ---p 00000000 00:00 0 
7f00a433e000-7f00a43df000 rw-p 00000000 00:00 0 
7f00a43df000-7f00a43e0000 ---p 00000000 00:00 0 
7f00a43e0000-7f00a4481000 rw-p 00000000 00:00 0 
7f00a4481000-7f00a4482000 ---p 00000000 00:00 0 
7f00a4482000-7f00a4523000 rw-p 00000000 00:00 0 
7f00a4523000-7f00a4524000 ---p 00000000 00:00 0 
7f00a4524000-7f00a45c5000 rw-p 00000000 00:00 0 
7f00a45c5000-7f00a45c6000 ---p 00000000 00:00 0 
7f00a45c6000-7f00a4667000 rw-p 00000000 00:00 0 
7f00a4667000-7f00a4668000 ---p 00000000 00:00 0 
7f00a4668000-7f00a4709000 rw-p 00000000 00:00 0 
7f00a4709000-7f00a470a000 ---p 00000000 00:00 0 
7f00a470a000-7f00a47ab000 rw-p 00000000 00:00 0 
7f00a47ab000-7f00a47ac000 ---p 00000000 00:00 0 
7f00a47ac000-7f00a484d000 rw-p 00000000 00:00 0 
7f00a484d000-7f00a484e000 ---p 00000000 00:00 0 
7f00a484e000-7f00a48ef000 rw-p 00000000 00:00 0 
7f00a48ef000-7f00a48f0000 ---p 00000000 00:00 0 
7f00a48f0000-7f00a4991000 rw-p 00000000 00:00 0 
7f00a4991000-7f00a4992000 ---p 00000000 00:00 0 
7f00a4992000-7f00a4a33000 rw-p 00000000 00:00 0 
7f00a4a33000-7f00a4a34000 ---p 00000000 00:00 0 
7f00a4a34000-7f00a4ad5000 rw-p 00000000 00:00 0 
7f00a4ad5000-7f00a4ad6000 ---p 00000000 00:00 0 
7f00a4ad6000-7f00a4b77000 rw-p 00000000 00:00 0 
7f00a4b77000-7f00a4b78000 ---p 00000000 00:00 0 
7f00a4b78000-7f00a4c19000 rw-p 00000000 00:00 0 
7f00a4c19000-7f00a4c1a000 ---p 00000000 00:00 0 
7f00a4c1a000-7f00a4cbb000 rw-p 00000000 00:00 0 
7f00a4cbb000-7f00a4cbc000 ---p 00000000 00:00 0 
7f00a4cbc000-7f00a4d5d000 rw-p 00000000 00:00 0 
7f00a4d5d000-7f00a4d5e000 ---p 00000000 00:00 0 
7f00a4d5e000-7f00a4dff000 rw-p 00000000 00:00 0 
7f00a4dff000-7f00a4e00000 ---p 00000000 00:00 0 
7f00a4e00000-7f00a4ea1000 rw-p 00000000 00:00 0 
7f00a4ea1000-7f00a4ea2000 ---p 00000000 00:00 0 
7f00a4ea2000-7f00a4f43000 rw-p 00000000 00:00 0 
7f00a4f43000-7f00a4f44000 ---p 00000000 00:00 0 
7f00a4f44000-7f00a4fe5000 rw-p 00000000 00:00 0 
7f00a4fe5000-7f00a4fe6000 ---p 00000000 00:00 0 
7f00a4fe6000-7f00a5087000 rw-p 00000000 00:00 0 
7f00a5087000-7f00a5088000 ---p 00000000 00:00 0 
7f00a5088000-7f00a5129000 rw-p 00000000 00:00 0 
7f00a5129000-7f00a512a000 ---p 00000000 00:00 0 
7f00a512a000-7f00a51cb000 rw-p 00000000 00:00 0 
7f00a51cb000-7f00a51cc000 ---p 00000000 00:00 0 
7f00a51cc000-7f00a526d000 rw-p 00000000 00:00 0 
7f00a526d000-7f00a526e000 ---p 00000000 00:00 0 
7f00a526e000-7f00a530f000 rw-p 00000000 00:00 0 
7f00a530f000-7f00a5310000 ---p 00000000 00:00 0 
7f00a5310000-7f00a53b1000 rw-p 00000000 00:00 0 
7f00a53b1000-7f00a53b2000 ---p 00000000 00:00 0 
7f00a53b2000-7f00a5453000 rw-p 00000000 00:00 0 
7f00a5453000-7f00a5454000 ---p 00000000 00:00 0 
7f00a5454000-7f00a7662000 rw-p 00000000 00:00 0 
7f00a7662000-7f00a768e000 r--p 00000000 fc:05 270939738                  /usr/lib64/libc.so.6
7f00a768e000-7f00a7803000 r-xp 0002c000 fc:05 270939738                  /usr/lib64/libc.so.6
7f00a7803000-7f00a7857000 r--p 001a1000 fc:05 270939738                  /usr/lib64/libc.so.6
7f00a7857000-7f00a7858000 ---p 001f5000 fc:05 270939738                  /usr/lib64/libc.so.6
7f00a7858000-7f00a785b000 r--p 001f5000 fc:05 270939738                  /usr/lib64/libc.so.6
7f00a785b000-7f00a785e000 rw-p 001f8000 fc:05 270939738                  /usr/lib64/libc.so.6
7f00a785e000-7f00a786b000 rw-p 00000000 00:00 0 
7f00a786b000-7f00a787a000 r--p 00000000 fc:05 270939741                  /usr/lib64/libm.so.6
7f00a787a000-7f00a78eb000 r-xp 0000f000 fc:05 270939741                  /usr/lib64/libm.so.6
7f00a78eb000-7f00a7945000 r--p 00080000 fc:05 270939741                  /usr/lib64/libm.so.6
7f00a7945000-7f00a7946000 r--p 000d9000 fc:05 270939741                  /usr/lib64/libm.so.6
7f00a7946000-7f00a7947000 rw-p 000da000 fc:05 270939741                  /usr/lib64/libm.so.6
7f00a7947000-7f00a7949000 r--p 00000000 fc:05 271023995                  /usr/lib64/libcrypt.so.2.0.0
7f00a7949000-7f00a795d000 r-xp 00002000 fc:05 271023995                  /usr/lib64/libcrypt.so.2.0.0
7f00a795d000-7f00a7976000 r--p 00016000 fc:05 271023995                  /usr/lib64/libcrypt.so.2.0.0
7f00a7976000-7f00a7977000 ---p 0002f000 fc:05 271023995                  /usr/lib64/libcrypt.so.2.0.0
7f00a7977000-7f00a7978000 r--p 0002f000 fc:05 271023995                  /usr/lib64/libcrypt.so.2.0.0
7f00a7978000-7f00a7981000 rw-p 00000000 00:00 0 
7f00a7981000-7f00a7992000 r--p 00000000 fc:05 271068897                  /usr/lib64/libgmp.so.10.4.0
7f00a7992000-7f00a7a0a000 r-xp 00011000 fc:05 271068897                  /usr/lib64/libgmp.so.10.4.0
7f00a7a0a000-7f00a7a21000 r--p 00089000 fc:05 271068897                  /usr/lib64/libgmp.so.10.4.0
7f00a7a21000-7f00a7a23000 r--p 0009f000 fc:05 271068897                  /usr/lib64/libgmp.so.10.4.0
7f00a7a23000-7f00a7a24000 rw-p 000a1000 fc:05 271068897                  /usr/lib64/libgmp.so.10.4.0
7f00a7a24000-7f00a7a27000 r--p 00000000 fc:05 271023970                  /usr/lib64/libz.so.1.2.11
7f00a7a27000-7f00a7a35000 r-xp 00003000 fc:05 271023970                  /usr/lib64/libz.so.1.2.11
7f00a7a35000-7f00a7a3b000 r--p 00011000 fc:05 271023970                  /usr/lib64/libz.so.1.2.11
7f00a7a3b000-7f00a7a3c000 ---p 00017000 fc:05 271023970                  /usr/lib64/libz.so.1.2.11
7f00a7a3c000-7f00a7a3d000 r--p 00017000 fc:05 271023970                  /usr/lib64/libz.so.1.2.11
7f00a7a3d000-7f00a7a3e000 rw-p 00000000 00:00 0 
7f00a7a41000-7f00a7a43000 rw-p 00000000 00:00 0 
7f00a7a43000-7f00a7a44000 r--p 00000000 fc:05 270939734                  /usr/lib64/ld-linux-x86-64.so.2
7f00a7a44000-7f00a7a69000 r-xp 00001000 fc:05 270939734                  /usr/lib64/ld-linux-x86-64.so.2
7f00a7a69000-7f00a7a73000 r--p 00026000 fc:05 270939734                  /usr/lib64/ld-linux-x86-64.so.2
7f00a7a73000-7f00a7a75000 r--p 0002f000 fc:05 270939734                  /usr/lib64/ld-linux-x86-64.so.2
7f00a7a75000-7f00a7a77000 rw-p 00031000 fc:05 270939734                  /usr/lib64/ld-linux-x86-64.so.2
7ffd63e17000-7ffd64616000 rw-p 00000000 00:00 0                          [stack]
7ffd64762000-7ffd64766000 r--p 00000000 00:00 0                          [vvar]
7ffd64766000-7ffd64768000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
make: *** [uncommon.mk:1096: encdb.h] Aborted (core dumped)
~~~

Comment 5 Vít Ondruch 2021-08-05 07:57:04 UTC
I have reported this to upstream:

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

Comment 6 Vít Ondruch 2021-08-05 08:10:49 UTC
GDB output:

~~~
$ gdb ./miniruby  
GNU gdb (GDB) Fedora 10.2-6.fc35
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./miniruby...
(gdb) r -I./lib -I. -I.ext/common  ./tool/generic_erb.rb -c -o encdb.h ./template/encdb.h.tmpl ./enc enc
Starting program: /builddir/build/BUILD/ruby-3.0.2/miniruby -I./lib -I. -I.ext/common  ./tool/generic_erb.rb -c -o encdb.h ./template/encdb.h.tmpl ./enc enc
Download failed: No route to host.  Continuing without debug info for /builddir/build/BUILD/ruby-3.0.2/system-supplied DSO at 0x7ffff7fc9000.
Download failed: No route to host.  Continuing without debug info for /lib64/libz.so.1.
Download failed: No route to host.  Continuing without debug info for /lib64/libgmp.so.10.
Download failed: No route to host.  Continuing without debug info for /lib64/libcrypt.so.2.
Download failed: No route to host.  Continuing without debug info for /lib64/libm.so.6.
Download failed: No route to host.  Continuing without debug info for /lib64/libc.so.6.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
vm_ccs_push.part.0.lto_priv.0 (klass=93824996623120, ccs=0x0, ci=0x22f100140003, cc=0x55555595ddf0) at /builddir/build/BUILD/ruby-3.0.2/vm_insnhelper.c:1579
1579	    if (UNLIKELY(ccs->len == ccs->capa)) {
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.34-1.fc35.x86_64 gmp-6.2.0-7.fc35.x86_64 libxcrypt-4.4.23-2.fc35.x86_64 zlib-1.2.11-30.fc35.x86_64
(gdb) where 
#0  vm_ccs_push.part.0.lto_priv.0 (klass=93824996623120, ccs=0x0, ci=0x22f100140003, cc=0x55555595ddf0) at /builddir/build/BUILD/ruby-3.0.2/vm_insnhelper.c:1579
#1  0x000055555579eb7e in vm_ccs_push (cc=0x55555595ddf0, ci=0x22f100140003, ccs=<optimized out>, klass=93824996623120) at ./include/ruby/internal/fl_type.h:237
#2  vm_search_cc (klass=klass@entry=93824996623120, ci=0x22f100140003) at /builddir/build/BUILD/ruby-3.0.2/vm_insnhelper.c:1718
#3  0x000055555579ed30 in rb_vm_search_method_slowpath (klass=93824996623120, ci=<optimized out>) at /builddir/build/BUILD/ruby-3.0.2/vm_insnhelper.c:1736
#4  vm_search_method_slowpath0 (cd_owner=93824996467240, cd=cd@entry=0x555555a358f0, klass=93824996623120) at /builddir/build/BUILD/ruby-3.0.2/vm_insnhelper.c:1758
#5  0x00005555557a5ff4 in vm_search_method_fastpath (klass=<optimized out>, cd=0x555555a358f0, cd_owner=<optimized out>) at /builddir/build/BUILD/ruby-3.0.2/vm_insnhelper.c:1824
#6  vm_sendish (ec=0x555555909c80, reg_cfp=0x7ffff7b84f68, cd=0x555555a358f0, block_handler=<optimized out>, method_explorer=<optimized out>) at /builddir/build/BUILD/ruby-3.0.2/vm_insnhelper.c:4526
#7  0x00005555557a95b8 in vm_exec_core (ec=0x555555909c80, initial=0) at /builddir/build/BUILD/ruby-3.0.2/insns.def:789
#8  0x00005555557c0ea0 in rb_vm_exec (ec=0x555555909c80, mjit_enable_p=<optimized out>) at /builddir/build/BUILD/ruby-3.0.2/vm.c:2172
#9  0x000055555572c5af in rb_load_with_builtin_functions (table=0x5555558f0240 <gc_table>, feature_name=0x55555588e0c3 "gc") at /builddir/build/BUILD/ruby-3.0.2/mini_builtin.c:48
#10 Init_builtin_gc () at /builddir/build/BUILD/ruby-3.0.2/gc.rbinc:212
#11 rb_call_builtin_inits () at /builddir/build/BUILD/ruby-3.0.2/inits.c:88
#12 ruby_opt_init (opt=0x7fffffffdfb0) at /builddir/build/BUILD/ruby-3.0.2/ruby.c:1520
#13 ruby_opt_init (opt=opt@entry=0x7fffffffdfb0) at /builddir/build/BUILD/ruby-3.0.2/ruby.c:1506
#14 0x000055555572e6e2 in load_file_internal (argp_v=140737488309936) at /builddir/build/BUILD/ruby-3.0.2/ruby.c:2181
#15 0x00005555556045a6 in rb_ensure (b_proc=0x55555572e230 <load_file_internal>, data1=140737488309936, e_proc=<optimized out>, data2=<optimized out>) at /builddir/build/BUILD/ruby-3.0.2/eval.c:1162
#16 0x0000555555730a65 in load_file (opt=0x7fffffffdfb0, script=1, f=<optimized out>, fname=<optimized out>, parser=93824996498920) at /builddir/build/BUILD/ruby-3.0.2/ruby.c:2323
#17 process_options (argc=6, argv=0x7fffffffe350, opt=0x7fffffffdfb0) at /builddir/build/BUILD/ruby-3.0.2/ruby.c:1960
#18 0x0000555555731551 in ruby_process_options (argc=11, argv=0x7fffffffe328) at /builddir/build/BUILD/ruby-3.0.2/ruby.c:230
#19 0x0000555555609de9 in ruby_options (argc=11, argv=0x7fffffffe328) at /builddir/build/BUILD/ruby-3.0.2/eval.c:138
#20 0x00005555555811e7 in main (argc=<optimized out>, argv=<optimized out>) at ./main.c:50
(gdb) list
1574	    }
1575	    else if (! vm_ci_markable(ci)) {
1576	        return;
1577	    }
1578	
1579	    if (UNLIKELY(ccs->len == ccs->capa)) {
1580	        if (ccs->capa == 0) {
1581	            ccs->capa = 1;
1582	            ccs->entries = ALLOC_N(struct rb_class_cc_entries_entry, ccs->capa);
1583	        }
(gdb) 
1584	        else {
1585	            ccs->capa *= 2;
1586	            REALLOC_N(ccs->entries, struct rb_class_cc_entries_entry, ccs->capa);
1587	        }
1588	    }
1589	    VM_ASSERT(ccs->len < ccs->capa);
1590	
1591	    const int pos = ccs->len++;
1592	    RB_OBJ_WRITE(klass, &ccs->entries[pos].ci, ci);
1593	    RB_OBJ_WRITE(klass, &ccs->entries[pos].cc, cc);
(gdb) 
~~~

Comment 7 Vít Ondruch 2021-08-05 08:51:50 UTC
This might be the culprit:

~~~
Breakpoint 1, vm_ccs_push (cc=0x55555595ddf0, ci=0x22f100140003, ccs=0x555555a31f80, klass=93824996623120) at ./include/ruby/internal/fl_type.h:237
237     return RBASIC(obj)->flags & flags;
(gdb) s
vm_ccs_push.part.0.lto_priv.0 (klass=93824996623120, ccs=0x0, ci=0x22f100140003, cc=0x55555595ddf0) at /builddir/build/BUILD/ruby-3.0.2/vm_insnhelper.c:1570
1570    vm_ccs_push(VALUE klass, struct rb_class_cc_entries *ccs, const struct rb_callinfo *ci, const struct rb_callcache *cc)
~~~

I probably don't understand why/how the `css` value changes to NULL.

Comment 8 Vít Ondruch 2021-08-09 10:25:25 UTC
So while the issues above are going to be fixed via https://bugs.ruby-lang.org/issues/18062, the https://bugs.ruby-lang.org/issues/17052 which was the original reason for disbling LTO remains unfixed.

Comment 9 Vít Ondruch 2021-08-09 11:26:23 UTC
@Florian, could you please help me understand what might be wrong with the kill call?

~~~
$ LC_ALL=C gdb --args ./miniruby -e'Process.kill("SIGSEGV",$$)'
GNU gdb (GDB) Fedora 10.2-6.fc35
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./miniruby...
warning: File "/builddir/build/BUILD/ruby-3.0.2/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
	add-auto-load-safe-path /builddir/build/BUILD/ruby-3.0.2/.gdbinit
line to your configuration file "/builddir/.gdbinit".
To completely disable this security protection add
	set auto-load safe-path /
line to your configuration file "/builddir/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
	info "(gdb)Auto-loading safe path"
(gdb) r
Starting program: /builddir/build/BUILD/ruby-3.0.2/miniruby -eProcess.kill\(\"SIGSEGV\",\$\$\)
Download failed: No route to host.  Continuing without debug info for /builddir/build/BUILD/ruby-3.0.2/system-supplied DSO at 0x7ffff7fc9000.
Download failed: No route to host.  Continuing without debug info for /lib64/libz.so.1.
Download failed: No route to host.  Continuing without debug info for /lib64/libgmp.so.10.
Download failed: No route to host.  Continuing without debug info for /lib64/libcrypt.so.2.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7c2699b in kill () at ../sysdeps/unix/syscall-template.S:120
Download failed: No route to host.  Continuing without source file /usr/src/debug/glibc-2.34-1.fc35.x86_64/signal/../sysdeps/unix/syscall-template.S.
120	../sysdeps/unix/syscall-template.S: No such file or directory.
Missing separate debuginfos, use: dnf debuginfo-install gmp-6.2.0-7.fc35.x86_64 libxcrypt-4.4.25-1.fc35.x86_64 zlib-1.2.11-30.fc35.x86_64
(gdb) bt
#0  0x00007ffff7c2699b in kill () at ../sysdeps/unix/syscall-template.S:120
#1  0x0000555555731f1b in rb_f_kill (argc=2, argv=0x7ffff7ae1048) at /builddir/build/BUILD/ruby-3.0.2/signal.c:481
#2  0x00005555557a3322 in vm_call_cfunc_with_frame (ec=0x5555559087f0, reg_cfp=0x7ffff7be0fa0, calling=<optimized out>) at /builddir/build/BUILD/ruby-3.0.2/vm_insnhelper.c:2929
#3  0x00005555557a5cf6 in vm_sendish (ec=0x5555559087f0, reg_cfp=0x7ffff7be0fa0, cd=0x555555a2a1d0, block_handler=<optimized out>, method_explorer=<optimized out>)
    at /builddir/build/BUILD/ruby-3.0.2/vm_callinfo.h:336
#4  0x00005555557a97a8 in vm_exec_core (ec=0x5555559087f0, initial=11) at /builddir/build/BUILD/ruby-3.0.2/insns.def:789
#5  0x00005555557c0e60 in rb_vm_exec (ec=0x5555559087f0, mjit_enable_p=<optimized out>) at /builddir/build/BUILD/ruby-3.0.2/vm.c:2172
#6  0x000055555560594f in rb_ec_exec_node (ec=ec@entry=0x5555559087f0, n=n@entry=0x55555591e010) at /builddir/build/BUILD/ruby-3.0.2/eval.c:317
#7  0x000055555560aa83 in ruby_run_node (n=0x55555591e010) at /builddir/build/BUILD/ruby-3.0.2/eval.c:375
#8  0x00005555555811ef in main (argc=<optimized out>, argv=<optimized out>) at ./main.c:50
(gdb) disas /m
Dump of assembler code for function kill:
120	in ../sysdeps/unix/syscall-template.S
   0x00007ffff7c26990 <+0>:	endbr64 
   0x00007ffff7c26994 <+4>:	mov    $0x3e,%eax
   0x00007ffff7c26999 <+9>:	syscall 
=> 0x00007ffff7c2699b <+11>:	cmp    $0xfffffffffffff001,%rax
   0x00007ffff7c269a1 <+17>:	jae    0x7ffff7c269a4 <kill+20>

121	in ../sysdeps/unix/syscall-template.S
122	in ../sysdeps/unix/syscall-template.S
   0x00007ffff7c269a3 <+19>:	ret    

123	in ../sysdeps/unix/syscall-template.S
   0x00007ffff7c269a4 <+20>:	mov    0x1b645d(%rip),%rcx        # 0x7ffff7ddce08
   0x00007ffff7c269ab <+27>:	neg    %eax
   0x00007ffff7c269ad <+29>:	mov    %eax,%fs:(%rcx)
   0x00007ffff7c269b0 <+32>:	or     $0xffffffffffffffff,%rax
   0x00007ffff7c269b4 <+36>:	ret    

End of assembler dump.
(gdb) disas /m rb_f_kill
Dump of assembler code for function rb_f_kill:
Address range 0x555555731cf0 to 0x55555573201c:
424	{
   0x0000555555731cf0 <+0>:	endbr64 
   0x0000555555731cf4 <+4>:	push   %r15
   0x0000555555731cf6 <+6>:	push   %r14
   0x0000555555731cf8 <+8>:	push   %r13
   0x0000555555731cfa <+10>:	push   %r12
   0x0000555555731cfc <+12>:	push   %rbp
   0x0000555555731cfd <+13>:	movslq %edi,%rbp
   0x0000555555731d00 <+16>:	push   %rbx
   0x0000555555731d01 <+17>:	sub    $0xd8,%rsp
   0x0000555555731d08 <+24>:	mov    %fs:0x28,%rax
   0x0000555555731d11 <+33>:	mov    %rax,0xc8(%rsp)
   0x0000555555731d19 <+41>:	xor    %eax,%eax

425	#ifndef HAVE_KILLPG
426	#define killpg(pg, sig) kill(-(pg), (sig))
427	#endif
428	    int sig;
429	    int i;
430	    VALUE str;
431	
432	    rb_check_arity(argc, 2, UNLIMITED_ARGUMENTS);
433	
434	    if (FIXNUM_P(argv[0])) {
   0x0000555555731d24 <+52>:	mov    (%rsi),%rdi
   0x0000555555731d27 <+55>:	mov    %rsi,%r12

435		sig = FIX2INT(argv[0]);
436	    }
437	    else {
438		str = argv[0];
   0x0000555555731d34 <+68>:	mov    %rdi,0x28(%rsp)

439		sig = signm2signo(&str, TRUE, FALSE, NULL);
   0x0000555555731d39 <+73>:	xor    %ecx,%ecx
   0x0000555555731d3b <+75>:	lea    0x28(%rsp),%rdi
   0x0000555555731d40 <+80>:	xor    %edx,%edx
   0x0000555555731d42 <+82>:	mov    $0x1,%esi
   0x0000555555731d47 <+87>:	call   0x555555731650 <signm2signo>
   0x0000555555731d4c <+92>:	mov    %eax,%r15d

440	    }
441	
442	    if (argc <= 1) return INT2FIX(0);

443	
444	    if (sig < 0) {
   0x0000555555731d4f <+95>:	test   %r15d,%r15d
   0x0000555555731d52 <+98>:	js     0x555555731e4b <rb_f_kill+347>
   0x0000555555731e42 <+338>:	test   %r15d,%r15d
   0x0000555555731e45 <+341>:	jns    0x555555731d58 <rb_f_kill+104>

445		sig = -sig;
   0x0000555555731e4b <+347>:	neg    %r15d
   0x0000555555731e4e <+350>:	mov    $0x1,%ebx
--Type <RET> for more, q to quit, c to continue without paging--
   0x0000555555731e53 <+355>:	jmp    0x555555731e8d <rb_f_kill+413>
   0x0000555555731e55 <+357>:	nopl   (%rax)

446		for (i=1; i<argc; i++) {
   0x0000555555731e7d <+397>:	lea    0x1(%rbx),%rax
   0x0000555555731e81 <+401>:	cmp    %rax,%rbp
   0x0000555555731e84 <+404>:	je     0x555555731f3c <rb_f_kill+588>
   0x0000555555731e8a <+410>:	mov    %rax,%rbx

447		    if (killpg(NUM2PIDT(argv[i]), sig) < 0)
   0x0000555555731e75 <+389>:	test   %eax,%eax
   0x0000555555731e77 <+391>:	js     0x555555731f06 <rb_f_kill+534>
   0x0000555555731e8d <+413>:	mov    (%r12,%rbx,8),%rdi

448			rb_sys_fail(0);
   0x0000555555731f06 <+534>:	xor    %edi,%edi
   0x0000555555731f08 <+536>:	call   0x5555555ffc80 <rb_sys_fail>
   0x0000555555731f0d <+541>:	nopl   (%rax)

449		}
450	    }
451	    else {
452		const rb_pid_t self = (GET_THREAD() == GET_VM()->ractor.main_thread) ? getpid() : -1;
   0x0000555555731d5f <+111>:	mov    $0xffffffff,%r13d
   0x0000555555731d65 <+117>:	mov    (%rax),%rbx
   0x0000555555731d7b <+139>:	mov    0x38(%rax),%rax
   0x0000555555731d7f <+143>:	cmp    %rax,0x28(%rbx)
   0x0000555555731d83 <+147>:	je     0x555555731ffb <rb_f_kill+779>
   0x0000555555731ffb <+779>:	call   0x55555557c5e0 <getpid@plt>
   0x0000555555732000 <+784>:	mov    %eax,%r13d
   0x0000555555732003 <+787>:	jmp    0x555555731d89 <rb_f_kill+153>

453		int wakeup = 0;
   0x0000555555731da8 <+184>:	movl   $0x0,0x14(%rsp)

454	
455		for (i=1; i<argc; i++) {
   0x0000555555731dff <+271>:	lea    0x1(%rbx),%rax
   0x0000555555731e03 <+275>:	cmp    %rax,%rbp
   0x0000555555731e06 <+278>:	je     0x555555731f30 <rb_f_kill+576>
   0x0000555555731e0c <+284>:	mov    %rax,%rbx
   0x0000555555731f1b <+555>:	lea    0x1(%rbx),%rax
   0x0000555555731f1f <+559>:	cmp    %rax,%rbp
   0x0000555555731f22 <+562>:	jne    0x555555731e0c <rb_f_kill+284>
   0x0000555555731f28 <+568>:	nopl   0x0(%rax,%rax,1)

456		    rb_pid_t pid = NUM2PIDT(argv[i]);
   0x0000555555731e0f <+287>:	mov    (%r12,%rbx,8),%rdi

457	
458		    if ((sig != 0) && (self != -1) && (pid == self)) {
   0x0000555555731dd2 <+226>:	test   %r15d,%r15d
   0x0000555555731dd5 <+229>:	setne  %dl
   0x0000555555731dd8 <+232>:	cmp    $0xffffffff,%r13d
   0x0000555555731ddc <+236>:	setne  %al
   0x0000555555731ddf <+239>:	test   %al,%dl
   0x0000555555731de1 <+241>:	je     0x555555731dec <rb_f_kill+252>
--Type <RET> for more, q to quit, c to continue without paging--
   0x0000555555731de3 <+243>:	cmp    %r14d,%r13d
   0x0000555555731de6 <+246>:	je     0x555555731eb0 <rb_f_kill+448>

459			int t;

460			/*
461			 * When target pid is self, many caller assume signal will be
462			 * delivered immediately and synchronously.
463			 */
464			switch (sig) {
   0x0000555555731eb0 <+448>:	cmp    $0x13,%r15d
   0x0000555555731eb4 <+452>:	ja     0x555555731ebd <rb_f_kill+461>
   0x0000555555731eb6 <+454>:	testb  $0x1,0x8(%rsp)
   0x0000555555731ebb <+459>:	jne    0x555555731f10 <rb_f_kill+544>

465			  case SIGSEGV:
466	#ifdef SIGBUS
467			  case SIGBUS:
468	#endif
469	#ifdef SIGKILL
470			  case SIGKILL:
471	#endif
472	#ifdef SIGILL
473			  case SIGILL:
474	#endif
475	#ifdef SIGFPE
476			  case SIGFPE:
477	#endif
478	#ifdef SIGSTOP
479			  case SIGSTOP:
480	#endif
481			    kill(pid, sig);
   0x0000555555731f10 <+544>:	mov    %r15d,%esi
   0x0000555555731f13 <+547>:	mov    %r14d,%edi
   0x0000555555731f16 <+550>:	call   0x55555557c920 <kill@plt>

482			    break;

483			  default:
484			    t = signal_ignored(sig);

485			    if (t) {

486				if (t < 0 && kill(pid, sig))
   0x0000555555731ef3 <+515>:	mov    %r15d,%esi
   0x0000555555731ef6 <+518>:	mov    %r14d,%edi
   0x0000555555731ef9 <+521>:	call   0x55555557c920 <kill@plt>
   0x0000555555731efe <+526>:	test   %eax,%eax
   0x0000555555731f00 <+528>:	je     0x555555731dff <rb_f_kill+271>

487				    rb_sys_fail(0);
488				break;
489			    }
490			    signal_enque(sig);

491			    wakeup = 1;
   0x0000555555731fc1 <+721>:	movl   $0x1,0x14(%rsp)
--Type <RET> for more, q to quit, c to continue without paging--

492			}
493		    }
494		    else if (kill(pid, sig) < 0) {
   0x0000555555731dec <+252>:	mov    %r15d,%esi
   0x0000555555731def <+255>:	mov    %r14d,%edi
   0x0000555555731df2 <+258>:	call   0x55555557c920 <kill@plt>
   0x0000555555731df7 <+263>:	test   %eax,%eax
   0x0000555555731df9 <+265>:	js     0x555555731f06 <rb_f_kill+534>

495			rb_sys_fail(0);
496		    }
497		}
498		if (wakeup) {
   0x0000555555731f30 <+576>:	mov    0x14(%rsp),%edx
   0x0000555555731f34 <+580>:	test   %edx,%edx
   0x0000555555731f36 <+582>:	jne    0x555555731fd0 <rb_f_kill+736>

499		    rb_threadptr_check_signal(GET_VM()->ractor.main_thread);
   0x0000555555731fea <+762>:	mov    (%rax),%rax

500		}
501	    }
502	    rb_thread_execute_interrupts(rb_thread_current());
503	
504	    return INT2FIX(i-1);
505	}
   0x0000555555731f82 <+658>:	mov    0xc8(%rsp),%rdx
   0x0000555555731f8a <+666>:	sub    %fs:0x28,%rdx
   0x0000555555731f93 <+675>:	jne    0x555555732017 <rb_f_kill+807>
   0x0000555555731f99 <+681>:	add    $0xd8,%rsp
   0x0000555555731fa0 <+688>:	pop    %rbx
   0x0000555555731fa1 <+689>:	pop    %rbp
   0x0000555555731fa2 <+690>:	pop    %r12
   0x0000555555731fa4 <+692>:	pop    %r13
   0x0000555555731fa6 <+694>:	pop    %r14
   0x0000555555731fa8 <+696>:	pop    %r15
   0x0000555555731faa <+698>:	ret    
   0x0000555555731fab <+699>:	nopl   0x0(%rax,%rax,1)
   0x0000555555732017 <+807>:	call   0x55555557ccb0 <__stack_chk_fail@plt>

506	
507	static struct {
508	    rb_atomic_t cnt[RUBY_NSIG];
509	    rb_atomic_t size;
510	} signal_buff;
511	#if RUBY_SIGCHLD
512	volatile unsigned int ruby_nocldwait;
513	#endif
514	
515	#define sighandler_t ruby_sighandler_t
516	
517	#ifdef USE_SIGALTSTACK
518	typedef void ruby_sigaction_t(int, siginfo_t*, void*);
519	#define SIGINFO_ARG , siginfo_t *info, void *ctx
520	#define SIGINFO_CTX ctx
521	#else
--Type <RET> for more, q to quit, c to continue without paging--q
Quit
(gdb) 
~~~

Comment 10 Vít Ondruch 2021-08-09 11:29:05 UTC
This is the latest LTO enabled scratch build if you find the SRPM handy:

https://koji.fedoraproject.org/koji/taskinfo?taskID=73549988

Comment 11 Florian Weimer 2021-08-09 11:33:57 UTC
I don't see anything wrong with it. If SIGSEGV is sent using kill, GDB intercepts the signal. The interception is based on signal number, not signal cause.

You can tell GDB to pass through the signal using:

handle SIGSEGV noprint nostop pass

Comment 12 Vít Ondruch 2021-08-11 15:34:51 UTC
You are right. Thank you.

I keep stumbling upon issues such as:

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

and that gets quickly confusing :(

Comment 14 Marek Polacek 2021-08-16 21:19:31 UTC
(In reply to Vít Ondruch from comment #13)

> @Marek, could you please confirm we have this fixed in GCC:
> 
> https://bugs.ruby-lang.org/issues/
> 18062?issue_count=249&issue_position=1&next_issue_id=17784#note-28
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101868

Martin Liska said that PR101868 had been fixed by r12-2254-gfedcf3c476aff753 but that is not present in the latest RHEL 9 gcc.  In fact, it hasn't been backported to any GCC 11.  I asked in the GCC Bugzilla if the backport is viable.

Comment 15 Vít Ondruch 2021-08-17 07:24:00 UTC
(In reply to Marek Polacek from comment #14)
> (In reply to Vít Ondruch from comment #13)
> 
> > @Marek, could you please confirm we have this fixed in GCC:
> > 
> > https://bugs.ruby-lang.org/issues/
> > 18062?issue_count=249&issue_position=1&next_issue_id=17784#note-28
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101868
> 
> Martin Liska said that PR101868 had been fixed by r12-2254-gfedcf3c476aff753
> but that is not present in the latest RHEL 9 gcc.  In fact, it hasn't been
> backported to any GCC 11.  I asked in the GCC Bugzilla if the backport is
> viable.

Thx.

https://github.com/ruby/ruby/commit/573eef7c897ff938539270e605445da13093d664

It seems that upstream put in place some workaround ^^ so it has probably lower importance for this case.

Comment 16 Vít Ondruch 2021-08-23 15:45:09 UTC
@Marek, @Jakub: Do you think you could provide some insights in the upstream ticket?

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

Comment 17 Vít Ondruch 2021-08-24 07:40:25 UTC
Cancelling the needinfo, since the issue was very likely resolved with upstream

Comment 18 Vít Ondruch 2021-08-25 10:30:00 UTC
This is enabled in Fedora now:

https://src.fedoraproject.org/rpms/ruby/c/1170d812fe0cd43aeddf7f15a63c2e6db3af8059

Comment 19 Vít Ondruch 2021-08-25 15:07:56 UTC
I have hit yet another issue on RHEL9:

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

Lets postpone this, since it is not really supper important IMO. Or is there any deadline @Marek?

Comment 20 Marek Polacek 2021-08-25 19:47:48 UTC
(In reply to Vít Ondruch from comment #19)
> I have hit yet another issue on RHEL9:
> 
> https://bugs.ruby-lang.org/issues/18133
> 
> Lets postpone this, since it is not really supper important IMO. Or is there
> any deadline @Marek?

Honestly I think I'd just disable LTO on i686, I don't think it's very important on that arch.

I don't think we have a strict deadline but I think best if this is done in RHEL 9 Beta.
I think if you disable LTO on i686 you're all set.

Comment 24 Vít Ondruch 2021-12-08 13:33:57 UTC
Upstream recently proposed two patches for backport [1]. Unfortunately, they breaks on other platforms.


[1]: https://bugs.ruby-lang.org/issues/18394

Comment 31 errata-xmlrpc 2022-05-17 14:02:37 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: ruby), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:2637


Note You need to log in before you can comment on or make changes to this bug.