Subject: Re: bug#75292: 31.0.50; igc: (file-error "Doing vfork" "Bad address")

From: Pip Cet <[email-masked]>
Date: Fri, 03 Jan 2025 18:24:47 +0000

"Ihor Radchenko" <[email-masked]> writes:

> Pip Cet <[email-masked]> writes:
>
>> After checking Eli's suggestion, an strace would be nice to find out
>> which of the pointers has gone bad.
>
> It can sometimes take one day to get the error. I am not sure if have
> enough disk space to record strace for so long. (I never used strace though)

Ouch.  I didn't manage to reproduce it; maybe I didn't try for long
enough.

For the record, Emacs still defaults to -O if no optimization option is
specified.  I fixed that in my tree a long time ago, and I forgot.  You
are running with optimization so it's entirely possible an automatic
variable which should have kept alive the string disappeared.

My suggestion would be

(strace -ff ...emacs... 2>&1) | egrep -50 '(fork|clone|spawn|exec)'

(grep -e on most distros, but you use gentoo, right?)

Note that this will attach to all of emacs's child processes
recursively, so there still might be a lot of output.

You can also attach to a running emacs process with strace -p; this
should allow you to kill the strace and attach gdb to emacs afterwards
for inspection purposes.

However, we have three possible explanations for this bug that we
already know about; maybe it's best to fix those three and see whether
the bug went away?

I've opened bug#75322 for the almost definitely buggy usage of
SAFE_ALLOCA in process.c and callproc.c, which might explain this (but I
don't think it does, TBH, because SAFE_ALLOCA would use alloca on your
system in this case, I think).

I don't think it's the 64KB stack allocation of call_process, either,
but that's also something we shouldn't do and there is a tiny chance
we somehow fail to mark a large C stack.

The most likely candidate right now is make_environment_block, which
happily stuffs string data pointers into an xmalloc'd block and goes
about its merry way without letting GC know about them.   I think it
would cause the problem you observed, but haven't managed to reproduce
it yet.  If I manage to do so, I'll push a fix.

Pip