Subject: bug#59874: Segfault from string-ref with negative 'k'

From: <[email-masked]>
Date: Wed, 7 Dec 2022 11:02:12 +0100

On Wed, Dec 07, 2022 at 08:50:09AM +0100, rose gibson via Bug reports for GUILE, GNU's Ubiquitous Extension Language wrote:
> hi,
> 
> i noticed that if i, on my system, run "guile" from a shell and then type into the command prompt that appears,
> 
> (string-ref "a string" -1)
> 
> guile appears to hang for a few seconds or so, and then prints the message "Segmentation fault (core dumped)".
> 
> i'm not really sure if this report is worth anything, it might just be some glitch in my distribution's build or something else unreproducable and weird, idk.  but i thought i would say something.  just in case.
> 
> this is with guile 3.0.8 on arch linux.  i didn't do anything special with respect to building guile myself or anything like that, it was (i'm pretty sure) just installed from the repositories.

Hi,

this is Debian GNU/Linux, x86_64, but a self-compiled Guile:

| tomas@trotzki:~$ guile
| GNU Guile 3.0.8.57-bc3b1
| Copyright (C) 1995-2022 Free Software Foundation, Inc.
| 
| Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
| This program is free software, and you are welcome to redistribute it
| under certain conditions; type `,show c' for details.
| 
| Enter `,help' for help.
| scheme@(guile-user)> (string-ref "a string" -1)
| ice-9/boot-9.scm:1685:16: In procedure raise-exception:
| Value out of range 0 to< 18446744073709551615: -1
| 
| Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
| scheme@(guile-user) [1]>

... so it's either fixed in the meantime, or there are differences
between our respective builds. Here, the bad index is caught, it
seems.

> i'm definitely curious what's up if anyone ever bothers to take the time figuring it out.
> 
> thanks :)

That's as much as I can do for now, $DAYJOB calling :)

Cheers
-- 
t