unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Stack allocation of Lisp objects
@ 2014-10-09  3:11 Stefan Monnier
  2014-10-09  7:09 ` Paul Eggert
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Monnier @ 2014-10-09  3:11 UTC (permalink / raw)
  To: emacs-devel

I started seeing occasional crashes (always during temacs's dump so
far), and while they come&go, they are completely reproducible when
they're here.  So I dug into it, and it looks like a problem with stack
allocation:

The crash I analyzed was within mark_object while looking at a `cons'
whose cdr is nil and whose car is a string whose address is 0xffffcbe0
which IIUC is on the stack.

Apparently there's an AUTO_STRING somewhere which we stick into a heap
allocated cons cell.  So of course, when the GC gets around to scan this
cons object, the stack-allocated string is long gone and overwritten by
unrelated data => crash.


        Stefan "going back to USE_STACK_LISP_OBJECTS=false"



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Stack allocation of Lisp objects
  2014-10-09  3:11 Stack allocation of Lisp objects Stefan Monnier
@ 2014-10-09  7:09 ` Paul Eggert
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Eggert @ 2014-10-09  7:09 UTC (permalink / raw)
  To: Stefan Monnier, emacs-devel

Stefan Monnier wrote:

> Apparently there's an AUTO_STRING somewhere which we stick into a heap
> allocated cons cell.

A plausible scenario is that you got bitten by a GCC bug, where GCC ignores 
___attribute__ ((aligned (8))) on your platform.  At least, that's how I 
reproduced the problem on x86.  I filed a GCC bug report 
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63495>.

If I'm right, the GCC bug cascaded into an Emacs portability bug: Emacs should 
use stack-based strings only if stack-base cons also works, as otherwise 
STACK_CONS could create a heap-based cons cell that points to a stack-based 
string, the symptom you observed.  I fixed that bug in Emacs trunk bzr 118080.

Because of this fix, Emacs no longer uses stack-based allocation on x86 + recent 
GCC, which is a bit of a downer.  It should still work with older GCC though, 
and I expect the GCC folks will fix the bug in newer GCC at some point.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-10-09  7:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-09  3:11 Stack allocation of Lisp objects Stefan Monnier
2014-10-09  7:09 ` Paul Eggert

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).