Eli Zaretskii writes: >> > Anyway, are you saying that stack marking doesn't work in optimized >> > code? We've been using this technique for the last 17 years without >> > problems; why would the fact that we have more than one thread change >> > that? The same arguments you submit are valid for a single-threaded >> > Emacs, right? >> >> Apparently so. I set up a single-threaded situation where I could >> redefine a function while exec_byte_code was running it, and got a >> segfault. I've gained some insights from debugging this version of the >> bug which I will put into a separate email. > > If this is the case, then I think we should protect the definition of > a running function from GC, in some way, either by making sure it is > referenced by some stack-based Lisp object, even in heavily optimized > code (e.g., by using 'volatile' qualifiers); or by some other method > that will ensure that definition is marked and not swept. Maybe code optimizers have improved over the last 17 years? I have patched Emacs with a 'volatile' on the definition of 'fun' in Ffuncall, and so far haven't managed to reproduce the bug with it: