Subject: Re: bug#31238: Dynamic Module Crash

From: Stefan Monnier <[email-masked]>
Date: Fri, 21 Sep 2018 18:48:40 -0400

>>> Emacs 25.3.1 crashes with a segfault when trying to print a value
>>> constructed (in certain ways) by a dynamic module.
>>> Reproduction: https://github.com/ubolonton/emacs-module-crash
>>> Context: https://github.com/ubolonton/emacs-module-rs/issues/2
>> This might be caused by commit 3eb93c07f7a60ac9ce8a16f10c3afd5a3a31243a,

IIUC that's just a wild guess, right?

>> which removed GC protection for module-allocated values.

Not really, no.  It just relied on another pre-existing mechanism.

> Unless anybody complains, I'll revert that commit.

Do we even know that reverting it circumvents this crash?

And IIRC this patch is not just an implementation detail, it changes the
module's API and ABI, so reverting it shouldn't be done lightly.

> Modules can store/use emacs_value objects in arbitrary ways;
> there's no way we can rely on stack scanning to reliably find them.

We don't blindly rely on stack scanning: there are functions to
(un)register other values stored in the (non-Lisp) heap.

The previous code wasn't magical either.

I don't know nearly enough about Rust's implementation strategy and the
`emacs` crate used to guess how its memory management could/should
interact with Emacs's.

        Stefan