# Racket crashes with "invalid memory reference"

**URL:** <https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206>\
**Category:** Questions & Answers\
**Created:** [August 10, 2023, 3:56am UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206 "2023-08-10T03:56:48Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![wurmli](https://avatars.discourse-cdn.com/v4/letter/w/dbc845/32.png) [@wurmli](https://racket.discourse.group/u/wurmli)\
**Post date:** [August 10, 2023, 3:56am UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206/1 "2023-08-10T03:56:48Z")

</div>

Does somebody know how to revert to expeditor with racket?

I had found on Racket Blog to v8.4 how to change from expeditor to readline. The result looks like this:

```scheme
wurmli@cirrus7:~$ racket
Welcome to Racket v8.9 [cs].
> ,input readline
> 
wurmli@cirrus7:~$ racket
Welcome to Racket v8.9 [cs].
invalid memory reference. Some debugging context lost

```

and the terminal has to be killed. The same happens when I try the "basic" example from Beautiful Racket:

```scheme
wurmli@cirrus7:~$ racket -I basic
Welcome to Racket v8.9 [cs].
invalid memory reference. Some debugging context lost

```

(I run Debian testing and a custom install of Racket v8.9 - as Debian is stuck with v8.7.)

---

<div class="post-metadata">

**Author:** ![mflatt](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/mflatt/32/6_2.png) [@mflatt](https://racket.discourse.group/u/mflatt)\
**Post date:** [August 10, 2023, 3:33pm UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206/2 "2023-08-10T15:33:29Z")

</div>

I think this is a problem with our strategy for creating a Racket distribution that runs on a wide range of Linux versions. Part of that involves statically linking to libtermcap, but old versions of libtermcap are not really compatible with newer versions of Linux. Specifically, it looks like the statically linked libtermcap interferes with initialization in libedit or libreadline, while Racket's default expeditor manages to side-step incompatibility in its initialization.

I'm not sure at what point our distibrutions should require newer version of Linux. Meanwhile, the only solution I can offer is to build from source or use a snapshot that's built on a Ubuntu 20 or 22.04 as available via [https://snapshot.racket-lang.org/](https://snapshot.racket-lang.org/).

---

<div class="post-metadata">

**Author:** ![wurmli](https://avatars.discourse-cdn.com/v4/letter/w/dbc845/32.png) [@wurmli](https://racket.discourse.group/u/wurmli)\
**Post date:** [August 10, 2023, 4:57pm UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206/3 "2023-08-10T16:57:05Z")

</div>

Thank you a lot!

Can you please advise me how to proceed after './configure && make' (which ran flawlessly): Do I have to deinstall the existing racket v8.9 first or can I just run 'sudo make install'? Or is there even a simpler way of just replacing some files by hand?

---

<div class="post-metadata">

**Author:** ![LiberalArtist](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/liberalartist/32/151_2.png) [@LiberalArtist](https://racket.discourse.group/u/LiberalArtist)\
**Post date:** [August 10, 2023, 5:17pm UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206/4 "2023-08-10T17:17:52Z")

</div>

> [@wurmli](#):
>
> Do I have to deinstall the existing racket v8.9 first or can I just run 'sudo make install'? Or is there even a simpler way of just replacing some files by hand?

This depends on how you installed Racket. If you used the installer script and chose a "Unix-style installation" or had the script put symlinks in your PATH etc., your PATH should also have a `racket-uninstall` script to reverse those actions. Otherwise, if you chose a self-contained installation, everything is in a single directory that you are free to remove.

---

<div class="post-metadata">

**Author:** ![mflatt](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/mflatt/32/6_2.png) [@mflatt](https://racket.discourse.group/u/mflatt)\
**Post date:** [August 10, 2023, 5:29pm UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206/5 "2023-08-10T17:29:25Z")

</div>

I think you probably want to install into `/usr/local`. In that case, do uninstall the old version (probably as @LiberalArtist describes), then use `./configure --prefix=/usr/local` (ok to do that in a place where you've already run `./configure` and built), and then `sudo make install`.

If you `make install` after a plain `./configure`, the "install" creates an in-place build instead of installing someplace like `/usr/local`. In that case, you can move the built directory around, and you can discard the `src` subdirectory, but you might need to update `PATH` to point to the build.

---

<div class="post-metadata">

**Author:** ![LiberalArtist](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/liberalartist/32/151_2.png) [@LiberalArtist](https://racket.discourse.group/u/LiberalArtist)\
**Post date:** [August 10, 2023, 6:32pm UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206/6 "2023-08-10T18:32:54Z")

</div>

> [@wurmli](#):
>
> I had found on Racket Blog to v8.4 how to change from expeditor to readline. The result looks like this:
> 
> ```scheme
> wurmli@cirrus7:~$ racket
> Welcome to Racket v8.9 [cs].
> > ,input readline
> > 
> wurmli@cirrus7:~$ racket
> Welcome to Racket v8.9 [cs].
> invalid memory reference. Some debugging context lost
> 
> ```
> 
> and the terminal has to be killed.

If it's useful, I looked into this a little with a Trixie podman container (from a Bookworm host). With just `libedit` installed, I got (having previously done `,input readline`):

```scheme
root@04bc7ba8ba59:/racket# ./bin/racket 
Welcome to Racket v8.9 [cs].
; Warning: no readline support (invalid memory reference. Some debugging context lost)
> 

```

I then did `raco pkg install readline-gpl` and `apt install libreadline8`, which got me to a worse state:

```scheme
root@04bc7ba8ba59:/racket# ./bin/racket 
Welcome to Racket v8.9 [cs].
invalid memory reference. Some debugging context lost

^C; user break [,bt for context]

^C; user break [,bt for context]
^C; user break [,bt for context]

,q
^[^[^[

^C; user break [,bt for context]
^C; user break [,bt for context]
^C; user break [,bt for context]

```

(And Ctrl-D didn't get me out of this.)

I'd thought about trying `racket-x86_64-linux-natipkg-3` because the Mac equivalents include libedit, but it looks like the Linux ones do not, and I definitely never advocate adding more to those packages other than as a last resort.

> [@wurmli](#):
>
> I run Debian testing and a custom install of Racket v8.9 - as Debian is stuck with v8.7.

FWIW, on Bookworm I get Racket by:

```scheme
sudo apt install guix
guix pull
guix install racket

```

(I maintain the Guix packaging of Racket.) We also have `racket-minimal`, `zuo`, and `chez-scheme-for-racket` (in addition to upstream `chez-scheme`) packaged.

I also expect, now that Bookworm has been released, David will probably update Racket in Debian testing soon, though if I were him I'd wait until after the imminent Racket 8.10 release. Generally he keeps the packaging in testing and backports very up-to-date. Sometimes he's landed updates in Debian before I;ve gotten them into Guix, even though Guix has a rolling release model.

> [@mflatt](#):
>
> I'm not sure at what point our distibrutions should require newer version of Linux. Meanwhile, the only solution I can offer is to build from source or use a snapshot that's built on a Ubuntu 20 or 22.04 as available via [https://snapshot.racket-lang.org/](https://snapshot.racket-lang.org/).

I don't have a principled answer, but, tangentially, this reminded me that I'd found in [Native library problem on package-build service · Issue #2 · libgit2-racket/libgit2 · GitHub](https://github.com/libgit2-racket/libgit2/issues/2) that your `mflatt/pkg-build-deps-min` Docker image is [still based on](https://github.com/racket/pkg-build/blob/71c379d2997049780186d104e5464780c28efb27/examples/docker/pkg-build-deps-min/Dockerfile) Ubuntu 16.04 Xenial, which is getting to be quite old indeed. At least when I wrote my [related notes](https://github.com/libgit2-racket/native-libs/blob/0c719ea327f30a1e5e7abc13ddfdd2ad1b065316/guix/old-stable-libc.scm#L22-L46), the Racket releases were building on the slightly newer Debian 9 Stretch (June 2017), which has been out of [LTS](https://wiki.debian.org/LTS/) support for a year and is only covered by the even-more-limited [ELTS](https://wiki.debian.org/LTS/Extended).

I saw in [What is the Racket roadmap? - #6 by mflatt](https://racket.discourse.group/t/what-is-the-racket-roadmap/2204/6) that you are planning to look at the `racket/draw` native libraries relatively soon. I don't have it all paged in, but I know I've had or heard about various issues and ideas at least somewhat related to native libraries; I can try to make a list relatively soon if something like that might be useful.

---

<div class="post-metadata">

**Author:** ![shhyou](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@shhyou](https://racket.discourse.group/u/shhyou)\
**Post date:** [August 10, 2023, 7:42pm UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206/7 "2023-08-10T19:42:05Z")

</div>

As a hack (it doesn't really solve the problem) here is a script that reverts the config back to using expeditor:

```plaintext
#lang racket
(find-system-path 'pref-file)
(get-preference 'xrepl-input-mode)
(put-preferences '(xrepl-input-mode) '(expeditor))

```

Without running the script, typing `(find-system-path 'pref-file)` into DrRacket also give you the path to the Racket preference file. Yon can manually edit the entry of `xrepl-input-mode` and change it back to `expeditor`.

---

<div class="post-metadata">

**Author:** ![wurmli](https://avatars.discourse-cdn.com/v4/letter/w/dbc845/32.png) [@wurmli](https://racket.discourse.group/u/wurmli)\
**Post date:** [August 11, 2023, 5:51am UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206/8 "2023-08-11T05:51:34Z")

</div>

> [![](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/liberalartist/96/151_2.png)](https://racket.discourse.group/u/LiberalArtist) [LiberalArtist](https://racket.discourse.group/u/LiberalArtist)  
> FWIW, on Bookworm I get Racket by:
> 
> sudo apt install guix  
> guix pull  
> guix install racket

Thank you and also Matthew for your help (which helped, at least mostly). As I never used guix I needed some time to "get it", but now I feel relatively comfortable using it. But using racket I run into some inconveniences and problems.

Is there a simple way to migrate the packages in ~/.local/share/racket/8.9 to ~/.local/share/racket/8.9-guix?

One problem I encounter and cannot resolve myself happens when I try to install a package (with raco or drracket): connecting to the package server I get a certificate verify error:

```scheme
Resolving "expect" via https://download.racket-lang.org/releases/8.9/catalog/
ssl-connect: connect failed (error:0A000086:SSL routines::certificate verify failed)

```

Do you have an idea how to resolve this issue?

---

<div class="post-metadata">

**Author:** ![LiberalArtist](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/liberalartist/32/151_2.png) [@LiberalArtist](https://racket.discourse.group/u/LiberalArtist)\
**Post date:** [August 11, 2023, 6:12am UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206/9 "2023-08-11T06:12:22Z")

</div>

> [@wurmli](#):
>
> Is there a simple way to migrate the packages in ~/.local/share/racket/8.9 to ~/.local/share/racket/8.9-guix?

You can use [`raco pkg migrate`](https://docs.racket-lang.org/pkg/cmdline.html#%28part._raco-pkg-migrate%29) or, in DrRacket, select `File > Package Manager` and use the `Copy from Version` tab in the dialog.

> [@wurmli](#):
>
> One problem I encounter and cannot resolve myself happens when I try to install a package (with raco or drracket): connecting to the package server I get a certificate verify error:
> 
> ```scheme
> Resolving "expect" via https://download.racket-lang.org/releases/8.9/catalog/
> ssl-connect: connect failed (error:0A000086:SSL routines::certificate verify failed)
> 
> ```
> 
> Do you have an idea how to resolve this issue?

For a lot of detail, see: [X.509 Certificates (GNU Guix Reference Manual)](https://guix.gnu.org/manual/devel/en/html_node/X_002e509-Certificates.html)

In brief:

1. Make sure you've started a new session since you did `sudo apt install guix` so the scripts installed to `/etc/profile.d/` will have been run.
2. Do `guix install nss-certs`.
3. If it doesn't work at this point, it would be a bug in the Guix packaging (I don't remember if I fixed this or not) not declaring that it needs OpenSSL environment variables at runtime. Please let me know if that's the case. If it is, a workaround is to do `guix install openssl`.

---

<div class="post-metadata">

**Author:** ![ryanc](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/ryanc/32/71_2.png) [@ryanc](https://racket.discourse.group/u/ryanc)\
**Post date:** [August 11, 2023, 6:41am UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206/10 "2023-08-11T06:41:54Z")

</div>

Racket logs the openssl certificate search path to the `openssl` topic. You can see that information with the following command line, for example:

```scheme
PLTSTDERR="debug@openssl error" raco pkg install ???

```

---

<div class="post-metadata">

**Author:** ![wurmli](https://avatars.discourse-cdn.com/v4/letter/w/dbc845/32.png) [@wurmli](https://racket.discourse.group/u/wurmli)\
**Post date:** [August 11, 2023, 6:42am UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206/11 "2023-08-11T06:42:00Z")

</div>

> 1. If it doesn't work at this point, it would be a bug in the Guix packaging (I don't remember if I fixed this or not) not declaring that it needs OpenSSL environment variables at runtime. Please let me know if that's the case. If it is, a workaround is to do `guix install openssl`.

Rebooting and 'guix install nss-certs' didn't help, but guix-installing openssl did.

On the other hand

```scheme
raco pkg migrate 8.9

```

did not actually migrate to 8.9-guix, but doing it by hand is not great problem.

---

<div class="post-metadata">

**Author:** ![LiberalArtist](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/liberalartist/32/151_2.png) [@LiberalArtist](https://racket.discourse.group/u/LiberalArtist)\
**Post date:** [August 11, 2023, 6:44am UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206/12 "2023-08-11T06:44:08Z")

</div>

> [@wurmli](#):
>
> > 1. If it doesn't work at this point, it would be a bug in the Guix packaging (I don't remember if I fixed this or not) not declaring that it needs OpenSSL environment variables at runtime. Please let me know if that's the case. If it is, a workaround is to do `guix install openssl`.
> 
> Rebooting and 'guix install nss-certs' didn't help, but guix-installing openssl did.

Thanks, I'll make sure to fix this in the 8.10 update.

---

<div class="post-metadata">

**Author:** ![LiberalArtist](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/liberalartist/32/151_2.png) [@LiberalArtist](https://racket.discourse.group/u/LiberalArtist)\
**Post date:** [September 9, 2023, 5:26pm UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206/13 "2023-09-09T17:26:01Z")

</div>

Hi @wurmli, thanks again for this report! The problem should be fixed by Guix commit [bce0fe8](https://git.savannah.gnu.org/cgit/guix.git/commit/?id=bce0fe8293a15331ed8b4e9a76354988f10e1ef5), which went out on the main Guix channel yesterday along with the update to Racket 8.10. You can get the update by running `guix pull && guix upgrade`. You'll still need to have `nss-certs` installed (that's what provides the certificates to be found), but you should no longer need to have `openssl` installed explicitly: you can remove it with `guix remove openssl` if you want.

---

<div class="post-metadata">

**Author:** ![wurmli](https://avatars.discourse-cdn.com/v4/letter/w/dbc845/32.png) [@wurmli](https://racket.discourse.group/u/wurmli)\
**Post date:** [September 9, 2023, 7:19pm UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206/14 "2023-09-09T19:19:24Z")

</div>

Thank you for letting me know. I'll update later as Debian provided 8.10 already some time ago. But in fact I like guix and sooner or later I'll use more of it.

Cheers, Hans Peter

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [September 10, 2023, 1:42pm UTC](https://racket.discourse.group/t/racket-crashes-with-invalid-memory-reference/2206/15 "2023-09-10T13:42:22Z")

</div>

Although much of this thread discusses how to get readline to work (which is a good goal) your reply seems to answer the original, literal question:

> [@wurmli](#):
>
> Does somebody know how to revert to expeditor with racket?

So I gave it a like. 😄

* * *

p.s. Assuming readline can't be made work in certain circumstances, how about prevention?

- Edit the mentioned blog post

- Make `,input readline` a no-op and warn when it can't work. (But idk how to detect that.)
