Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 907806 - sys-apps/sandbox-2.29: lto1 deadlock during gcc compilation (recursive __sb_dump_backtrace calls)
Summary: sys-apps/sandbox-2.29: lto1 deadlock during gcc compilation (recursive __sb_d...
Status: UNCONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Sandbox (show other bugs)
Hardware: AMD64 Linux
: Low normal (vote)
Assignee: Sandbox Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-03 19:24 UTC by Jaak Ristioja
Modified: 2023-06-23 03:40 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jaak Ristioja 2023-06-03 19:24:58 UTC
I've recently been experiencing some packages failing to emerge due to some processes hanging. In one such case I finally managed to get the following backtrace from a hanging lto1 process, which looks like a deadlock while trying to lock a mutex and seems to be involved to libsandbox recursively calling open() due to a call to abort().

(gdb) thread apply all bt

Thread 1 (Thread 0x7f0067982ac0 (LWP 1048751) "lto1-wpa-stream"):
#0  0x00007f0067a0a4ef in ?? () from target:/lib64/libc.so.6
#1  0x00007f0067a10962 in pthread_mutex_lock () from target:/lib64/libc.so.6
#2  0x00007f0068091c1d in ?? () from target:/usr/lib64/libsandbox.so
#3  0x00007f0068095838 in open () from target:/usr/lib64/libsandbox.so
#4  0x00000000028023c1 in backtrace_open ()
#5  0x000000000280207e in fileline_initialize ()
#6  0x000000000280221c in backtrace_pcinfo ()
#7  0x000000000280174b in unwind ()
#8  0x000000000285ce74 in _Unwind_Backtrace ()
#9  0x0000000002801849 in backtrace_full ()
#10 0x0000000002794df2 in diagnostic_action_after_output(diagnostic_context*, diagnostic_t) ()
#11 0x00000000027969e2 in diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*) ()
#12 0x0000000002797031 in diagnostic_impl(rich_location*, diagnostic_metadata const*, int, char const*, __va_list_tag (*) [1], diagnostic_t) ()
#13 0x0000000002798e80 in internal_error(char const*, ...) ()
#14 0x0000000001172781 in crash_signal(int) ()
#15 <signal handler called>
#16 0x00007f0067a0f3ac in ?? () from target:/lib64/libc.so.6
#17 0x00007f00679bf8b6 in raise () from target:/lib64/libc.so.6
#18 0x00007f00679a97fc in abort () from target:/lib64/libc.so.6
#19 0x00007f00680994d3 in ?? () from target:/usr/lib64/libsandbox.so
#20 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#21 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#22 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#23 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#24 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#25 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#26 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#27 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#28 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#29 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#30 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#31 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#32 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#33 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#34 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#35 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#36 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#37 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#38 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#39 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#40 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#41 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#42 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#43 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#44 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#45 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#46 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#47 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#48 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#49 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#50 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#51 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#52 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#53 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#54 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#55 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#56 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#57 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#58 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#59 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#60 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#61 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#62 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#63 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#64 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#65 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#66 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#67 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#68 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#69 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#70 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#71 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#72 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#73 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#74 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#75 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#76 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#77 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#78 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#79 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#80 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#81 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#82 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#83 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#84 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#85 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#86 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#87 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#88 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#89 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#90 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#91 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#92 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#93 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#94 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#95 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#96 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#97 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#98 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#99 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#100 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#101 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#102 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#103 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#104 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#105 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#106 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#107 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#108 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#109 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#110 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#111 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#112 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#113 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#114 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#115 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#116 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#117 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#118 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#119 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#120 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#121 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#122 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#123 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#124 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#125 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#126 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#127 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#128 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#129 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#130 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#131 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#132 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#133 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#134 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#135 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#136 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#137 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#138 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#139 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#140 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#141 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#142 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#143 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#144 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#145 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#146 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#147 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#148 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#149 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#150 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#151 0x00007f0068099899 in ?? () from target:/usr/lib64/libsandbox.so
#152 0x00007f0068091a54 in ?? () from target:/usr/lib64/libsandbox.so
#153 0x00007f00680993cd in ?? () from target:/usr/lib64/libsandbox.so
#154 0x00007f00680994c9 in ?? () from target:/usr/lib64/libsandbox.so
#155 0x00007f006809a277 in ?? () from target:/usr/lib64/libsandbox.so
#156 0x00007f0068091501 in ?? () from target:/usr/lib64/libsandbox.so
#157 0x00007f0068091c48 in ?? () from target:/usr/lib64/libsandbox.so
#158 0x00007f0068095838 in open () from target:/usr/lib64/libsandbox.so
#159 0x0000000000a7545c in lto_read_section_data(lto_file_decl_data*, long, unsigned long) ()
#160 0x0000000000a75604 in get_section_data(lto_file_decl_data*, lto_section_type, char const*, int, unsigned long*) ()
#161 0x0000000000f61672 in lto_get_raw_section_data(lto_file_decl_data*, lto_section_type, char const*, int, unsigned long*) ()
#162 0x0000000000f5bf50 in copy_function_or_variable(symtab_node*) ()
#163 0x0000000000f5cb03 in lto_output() ()
#164 0x000000000102a277 in write_lto() ()
#165 0x000000000102a96b in ipa_write_optimization_summaries(lto_symtab_encoder_d*) ()
#166 0x0000000000a56178 in stream_out(char*, lto_symtab_encoder_d*, int) ()
#167 0x0000000000a5631d in stream_out_partitions_1(char*, int, int, int) ()
#168 0x0000000000a563f5 in stream_out_partitions(char*, int, int, int, bool) ()
#169 0x0000000000a56a97 in lto_wpa_write_files() ()
#170 0x0000000000a56fec in do_whole_program_analysis() ()
#171 0x0000000000a570fb in lto_main() ()
#172 0x0000000001172aa9 in compile_file() ()
#173 0x0000000001175ad9 in do_compile(bool) ()
#174 0x0000000001175ec3 in toplev::main(int, char**) ()
#175 0x00000000027707eb in main ()

I re-compiled sys-apps/sandbox with -ggdb and can hopefully post a better backtrace should this happen again, but perhaps the above backtrace might also be sufficient.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-06-04 02:57:55 UTC
Note that there's two bugs here - the other bug being that GCC is ICEing. If you can reproduce that part, please file another bug (and follow https://wiki.gentoo.org/wiki/Gcc-ICE-reporting-guide). Although I'm a bit worried it's the "standard" LTO ICE, see https://bugs.gentoo.org/900519#c6.
Comment 2 Jaak Ristioja 2023-06-04 20:13:37 UTC
It doesn't look like an GCC ICE, but caused by libsandbox only (and perhaps related to running low on available memory). Here's an updated backtrace:

#0  0x00007f7c786f24ef in ?? () from target:/lib64/libc.so.6
#1  0x00007f7c786f8962 in pthread_mutex_lock () from target:/lib64/libc.so.6
#2  0x00007f7c78d7b0a0 in sb_lock () at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/lock.c:16
#3  0x00007f7c78d79c1d in before_syscall (dirfd=dirfd@entry=-100, sb_nr=-3, func=func@entry=0x7f7c78d8440e "open_rd", file=file@entry=0x22a5c73 "/proc/self/exe", flags=flags@entry=524288) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/libsandbox.c:1057
#4  0x00007f7c78d7a508 in before_syscall_open_int (dirfd=dirfd@entry=-100, sb_nr=<optimized out>, sb_nr@entry=5, func=func@entry=0x7f7c78d84eb2 "open", file=file@entry=0x22a5c73 "/proc/self/exe", flags=flags@entry=524288) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/libsandbox.c:1101
#5  0x00007f7c78d7d838 in open_DEFAULT (pathname=0x22a5c73 "/proc/self/exe", flags=524288) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/wrapper-funcs/__wrapper_simple.c:52
#6  0x000000000175ee9f in backtrace_open ()
#7  0x0000000001766ed9 in fileline_initialize ()
#8  0x00000000017670f6 in unwind ()
#9  0x0000000001bee244 in _Unwind_Backtrace (trace=0x1767030 <unwind>, trace_argument=0x7ffd52578bc0) at /var/tmp/portage/sys-devel/gcc-12.3.1_p20230526/work/gcc-12-20230526/libgcc/unwind.inc:309
#10 0x000000000175da2d in backtrace_full ()
#11 0x0000000001738551 in diagnostic_action_after_output(diagnostic_context*, diagnostic_t) ()
#12 0x000000000174121f in diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*) ()
#13 0x0000000001741a21 in diagnostic_impl(rich_location*, diagnostic_metadata const*, int, char const*, __va_list_tag (*) [1], diagnostic_t) ()
#14 0x0000000001726ed8 in internal_error(char const*, ...) ()
#15 0x0000000000b39c84 in crash_signal(int) ()
#16 <signal handler called>
#17 0x00007f7c786f73ac in ?? () from target:/lib64/libc.so.6
#18 0x00007f7c786a78b6 in raise () from target:/lib64/libc.so.6
#19 0x00007f7c786917fc in abort () from target:/lib64/libc.so.6
#20 0x00007f7c78d814d3 in __sb_ebort (file=file@entry=0x7f7c78d85440 "/var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_write_fd.c", func=func@entry=0x7f7c78d854a0 <__func__.0> "sb_copy_file_to_fd", line_num=line_num@entry=22, format=format@entry=0x7f7c78d8570e "malloc(%zu)\n") at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_efuncs.c:138
#21 0x00007f7c78d82277 in __xmalloc (size=size@entry=4096, file=file@entry=0x7f7c78d85440 "/var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_write_fd.c", func=func@entry=0x7f7c78d854a0 <__func__.0> "sb_copy_file_to_fd", line=line@entry=22) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_memory.c:37
#22 0x00007f7c78d81899 in sb_copy_file_to_fd (file=file@entry=0x7f7c78d92340 <path> "/proc/142342/cmdline", ofd=ofd@entry=2) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_write_fd.c:22
#23 0x00007f7c78d79a54 in __sb_dump_backtrace () at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/libsandbox.c:425
#24 0x00007f7c78d813cd in sb_dump_backtrace () at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_efuncs.c:121
#25 0x00007f7c78d814c9 in __sb_ebort (file=file@entry=0x7f7c78d85440 "/var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_write_fd.c", func=func@entry=0x7f7c78d854a0 <__func__.0> "sb_copy_file_to_fd", line_num=line_num@entry=22, format=format@entry=0x7f7c78d8570e "malloc(%zu)\n") at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_efuncs.c:134
#26 0x00007f7c78d82277 in __xmalloc (size=size@entry=4096, file=file@entry=0x7f7c78d85440 "/var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_write_fd.c", func=func@entry=0x7f7c78d854a0 <__func__.0> "sb_copy_file_to_fd", line=line@entry=22) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_memory.c:37
#27 0x00007f7c78d81899 in sb_copy_file_to_fd (file=file@entry=0x7f7c78d92340 <path> "/proc/142342/cmdline", ofd=ofd@entry=2) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_write_fd.c:22
#28 0x00007f7c78d79a54 in __sb_dump_backtrace () at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/libsandbox.c:425
#29 0x00007f7c78d813cd in sb_dump_backtrace () at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_efuncs.c:121
#30 0x00007f7c78d814c9 in __sb_ebort (file=file@entry=0x7f7c78d85440 "/var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_write_fd.c", func=func@entry=0x7f7c78d854a0 <__func__.0> "sb_copy_file_to_fd", line_num=line_num@entry=22, format=format@entry=0x7f7c78d8570e "malloc(%zu)\n") at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_efuncs.c:134
#31 0x00007f7c78d82277 in __xmalloc (size=size@entry=4096, file=file@entry=0x7f7c78d85440 "/var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_write_fd.c", func=func@entry=0x7f7c78d854a0 <__func__.0> "sb_copy_file_to_fd", line=line@entry=22) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_memory.c:37
#32 0x00007f7c78d81899 in sb_copy_file_to_fd (file=file@entry=0x7f7c78d92340 <path> "/proc/142342/cmdline", ofd=ofd@entry=2) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_write_fd.c:22
#33 0x00007f7c78d79a54 in __sb_dump_backtrace () at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/libsandbox.c:425
#34 0x00007f7c78d813cd in sb_dump_backtrace () at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_efuncs.c:121
#35 0x00007f7c78d814c9 in __sb_ebort (file=file@entry=0x7f7c78d84030 "/var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/libsandbox.c", func=func@entry=0x7f7c78d844f8 <__func__.5> "resolve_path", line_num=line_num@entry=240, format=format@entry=0x7f7c78d8570e "malloc(%zu)\n") at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_efuncs.c:134
#36 0x00007f7c78d82277 in __xmalloc (size=size@entry=8192, file=file@entry=0x7f7c78d84030 "/var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/libsandbox.c", func=func@entry=0x7f7c78d844f8 <__func__.5> "resolve_path", line=line@entry=240) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsbutil/sb_memory.c:37
#37 0x00007f7c78d79501 in resolve_path (path=path@entry=0x1021e0b0 "/var/tmp/portage/sys-devel/gcc-12.3.1_p20230526/temp/ccQrIfmo.ltrans21.o", follow_link=follow_link@entry=0) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/libsandbox.c:240
#38 0x00007f7c78d79c48 in check_syscall (sbcontext=0x7f7c78d90080 <sbcontext>, flags=65, file=0x1021e0b0 "/var/tmp/portage/sys-devel/gcc-12.3.1_p20230526/temp/ccQrIfmo.ltrans21.o", func=0x7f7c78d84417 "open_wr", sb_nr=-4) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/libsandbox.c:894
#39 before_syscall (dirfd=dirfd@entry=-100, sb_nr=-4, func=func@entry=0x7f7c78d84417 "open_wr", file=file@entry=0x1021e0b0 "/var/tmp/portage/sys-devel/gcc-12.3.1_p20230526/temp/ccQrIfmo.ltrans21.o", flags=flags@entry=65) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/libsandbox.c:1069
#40 0x00007f7c78d7a508 in before_syscall_open_int (dirfd=dirfd@entry=-100, sb_nr=<optimized out>, sb_nr@entry=5, func=func@entry=0x7f7c78d84eb2 "open", file=file@entry=0x1021e0b0 "/var/tmp/portage/sys-devel/gcc-12.3.1_p20230526/temp/ccQrIfmo.ltrans21.o", flags=flags@entry=65) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/libsandbox.c:1101
#41 0x00007f7c78d7d838 in open_DEFAULT (pathname=0x1021e0b0 "/var/tmp/portage/sys-devel/gcc-12.3.1_p20230526/temp/ccQrIfmo.ltrans21.o", flags=65) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/wrapper-funcs/__wrapper_simple.c:52
#42 0x000000000065939a in lto_obj_file_open(char const*, bool) ()
#43 0x00000000006617cf in stream_out_partitions_1(char*, int, int, int) ()
#44 0x0000000000662e7c in lto_main() ()
#45 0x0000000000b39e71 in compile_file() ()
#46 0x000000000062d29d in toplev::main(int, char**) ()
#47 0x000000000062dae4 in main ()

Some backtraces are longer than 200 frames with many recursions of __xmalloc -> __sb_ebort -> sb_dump_backtrace -> __sb_dump_backtrace -> sb_copy_file_to_fd -> __xmalloc -> ...
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-06-04 20:15:54 UTC
You can see it's ICEing because of: 
#14 0x0000000001726ed8 in internal_error(char const*, ...) ()
#15 0x0000000000b39c84 in crash_signal(int) ()
Comment 4 Jaak Ristioja 2023-06-04 20:18:01 UTC
(In reply to Sam James from comment #3)
> You can see it's ICEing because of: 
> #14 0x0000000001726ed8 in internal_error(char const*, ...) ()
> #15 0x0000000000b39c84 in crash_signal(int) ()

Yes, but afaict this happens due to abort() getting called in libsandbox.
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-06-04 20:18:15 UTC
(In reply to Sam James from comment #3)
> You can see it's ICEing because of: 
> #14 0x0000000001726ed8 in internal_error(char const*, ...) ()
> #15 0x0000000000b39c84 in crash_signal(int) ()

.. but I see your point that __sb_dump_backtrace comes first. Still wondering what's happening with GCC though.
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-06-04 20:18:20 UTC
right, got it