On Sun, 2022-11-20 at 13:47 -0500, Stefan Monnier wrote: > > The follow elisp snipper is an example of code that when compiled > > under > > this branch, crashes Emacs: > > ;; -*- lexical-binding: t; -*- > > (defun fault-function () > >   (let ((a [1 2 3])) > >     (aset a 0 5) > >     a)) > > I'm not deluded enough to think it's currently impossible to crash > Emacs > with a well-crafted piece of ELisp code, but we do aim for that, so > this > would be a significant step backwards :-( > > Can we change your patch so that it makes the section writable rather > than ".rodata"? > Indeed, making static lisp data variables constants was an afterthought before I pushed the first draft. Currently, it's line 2889 in src/comp.c@320e9ab048. Removing the call to `gcc_jit_type_get_const' should make them writeable as usual. However, as part of emitting the lisp data as read only, I also made it so that such objects have their GC mark bit set, so that GC does not crash Emacs as it attemps to mark these objects, skipping them instead. This property can therefore be used to check whether an object being modified is mutable or not à la `CHECK_IMPURE'. A more general variant of the macro, `CHECK_MUTABLE' could be defined as (PURE_P (ptr) || object_marked_p (ptr) ? pure_wire_error (obj) : (void) 0) This lets us keep them as read-only and preventing illegal modifications resulting in a crash. If this sounds good, I try adding these changes soon, otherwise remove the call to `gcc_jit_type_get_const'. Best, Vibhav -- Vibhav Pant vibhavp@gmail.com GPG: 7ED1 D48C 513C A024 BE3A 785F E3FB 28CB 6AB5 9598