GNU bug report logs -
#16060
Attempt to mutate a literal pair results in segfault (master)
Previous Next
Full log
View this message in rfc822 format
Hi,
Pieter Slabbert <blob626 <at> gmail.com> writes:
> When I try to load a file which contains
> (set-car! '(0 . ()) 1)
>
> Guile segfaults .
> if I enter the same thing into the interpreter it works fine.
According to the R5RS, it is "an error" to mutate literals, and
implementations are not required to detect this error. In other words,
the behavior is unspecified, like signed integer overflow in C.
Currently, what happens is this: on the stable-2.0 branch, and in the
interpreter on master, you are effectively modifying the code itself.
In compiled code on master, literals are in read-only memory, which is
why attempting to mutate it leads to a segfault. It is similar to what
happens in C if you attempt to mutate a character in a string literal.
Perhaps in 2.2.x we can support a debugging mode where compiled code
adds extra checks, but this is a wishlist item.
> I tried the same thing in chibi and it complained about try to mutate
> an immutable pair. Fixed it in my code but the segfault made it a lot
> harder to find
>
> I installed guile from git. Version gives me 2.1.0.526-7f710
The master branch of guile is very much a work-in-progress, with a major
new implementation of the VM, compiler, and loader recently pushed. The
ABI is not yet stabilized, which means that occasionally you may need to
"make clean" and rebuild everything, including any external libraries
that use libguile.
For now, you might be happier with the 'stable-2.0' branch in git.
Regards,
Mark
This bug report was last modified 1 year and 330 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.