Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Circumvent gcc 12.2.0 segfault #23950

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jukuisma
Copy link
Contributor

@jukuisma jukuisma commented Feb 7, 2025

  • Mark this if you consider it ready to merge
  • I've added tests (optional)
  • I wrote some lines in the book (optional)

Description

gcc 12.2.0 previously segfaulted trying to inline a bunch of code. This can be reproduced prior to these patches with:

$ make clean && ./configure && CFLAGS=-O2 make -j 4

which produces:

during RTL pass: expand
p/pickle/plugin.c: In function ‘pickle_encode’:
p/pickle/plugin.c:632:17: internal compiler error: Segmentation fault
  632 |                 switch (ob) {
      |                 ^~~~~~
0x7fc4bd56604f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x7fc4bd697f7a __memset_avx512_unaligned_erms
        ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:236
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-12/README.Bugs> for instructions.

gcc 14.2.0 doesn't segfault, but tries and fails to allocate 32G of memory:

cc1: out of memory allocating 34359738352 bytes after a total of 3411968 bytes
╭─vagrant@testing ~/scratch/radare2 (master)
╰─➤ sudo dmesg | tail -3
[ 4137.211190] __vm_enough_memory: pid: 90750, comm: cc1, bytes: 34359742464 not enough memory for the allocation
[ 4137.211210] __vm_enough_memory: pid: 90750, comm: cc1, bytes: 34359635968 not enough memory for the allocation
[ 4137.211217] __vm_enough_memory: pid: 90750, comm: cc1, bytes: 34359873536 not enough memory for the allocation

The root cause requires additional debugging and should possibly be reported upstream to the gcc bug tracker. However, these patches fix compilation for now with gcc 12.2.0 using CLFAGS=-O2.

gcc 12.2.0 previously segfaulted trying to inline a bunch of code. This
can be reproduced prior to these patches with:

```bash
$ make clean && ./configure && CFLAGS=-O2 make -j 4
```

which produces:

```
during RTL pass: expand
p/pickle/plugin.c: In function ‘pickle_encode’:
p/pickle/plugin.c:632:17: internal compiler error: Segmentation fault
  632 |                 switch (ob) {
      |                 ^~~~~~
0x7fc4bd56604f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x7fc4bd697f7a __memset_avx512_unaligned_erms
        ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:236
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-12/README.Bugs> for instructions.
```

gcc 14.2.0 doesn't segfault, but tries and fails to allocate 32G of
memory:

```
cc1: out of memory allocating 34359738352 bytes after a total of 3411968 bytes
```
```
╭─vagrant@testing ~/scratch/radare2 (master)
╰─➤ sudo dmesg | tail -3
[ 4137.211190] __vm_enough_memory: pid: 90750, comm: cc1, bytes: 34359742464 not enough memory for the allocation
[ 4137.211210] __vm_enough_memory: pid: 90750, comm: cc1, bytes: 34359635968 not enough memory for the allocation
[ 4137.211217] __vm_enough_memory: pid: 90750, comm: cc1, bytes: 34359873536 not enough memory for the allocation
```

The root cause requires additional debugging and should possibly be
reported upstream to the gcc bug tracker. However, these patches fix
compilation for now with gcc 12.2.0 using `CLFAGS=-O2`.
@jukuisma jukuisma marked this pull request as draft February 7, 2025 18:56
@jukuisma
Copy link
Contributor Author

jukuisma commented Feb 7, 2025

This compiled no problem yesterday night, but segfaults again today. I don't think these patches are stable and fix the issue at hand. Pushing a Draft PR so that there's some documentation of what's been tried and how to reproduce this somewhere else than on just my machine.

I'm totally unreachable for the next week and open to anyone else taking a stab at this. I'll continue wrestling with this when I'm back.

@jukuisma
Copy link
Contributor Author

jukuisma commented Feb 7, 2025

Started failing again after rebasing. Pulling more stuff out of the switch might be worth a try. Horrible hack, but might fix the segfault. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant