To cut a long story short, I'm trying to use userland-execve
to wrap various compiler components. Specifically, I'm following along with Linux From Scratch 12.0, using the tools from earlier chapters wrapped with userland-execve
. So far, I've made it up to GCC pass 2, and this is where the story begins.
Somewhere during this build, make
fails because one of the subcommands wrapped with userland-execve
failed. Specifically, cc1plus
(the internal GCC program for compiling C++ to assembly) ended up segfaulting. Originally, I assumed that something went wrong with an earlier build step that caused the segfault, but I narrowed it down and found that I could reliably get cc1plus
-- when executed exactly the same way-- to segfault under userland-execve
, but not to segfault when executed normally. Other invocations of cc1plus
with userland-execve
succeed, even within the same make
invocation, so something goes wrong during this specific command invocation.
I spent some time creating a script that reproduces this issue in isolation, and here's what I ended up with: https://development-content.brioche.dev/files/userland-execve-segfault.tar.gz (SHA256: 9b74194f54c9a83cb601015da72390f567da2ed98b78ff9955528d737f0c1138
)
This tarfile contains a repro.sh
script which, when run, executes cc1plus
through userland-execve
, then segfaults. If you call cc1plus
directly (by commenting out line 7), then the command succeeds. The only requirement for this script is that userland-execve
is available on $PATH
-- everything else is fully contained in the tarfile, so this should run on any x86-64 Linux system.
Also in the tarfile are two strace
traces: one when calling with userland-execve
and one when calling without.