Skip to content

Conversation

@mflatt
Copy link
Contributor

@mflatt mflatt commented Nov 27, 2025

This commit repairs a problem created by the previous commit (#994), and it further repairs some hashtable operations alog the same lines as vector operations in that commit.

The problem was exposed by Racket's test suite, eventually. Unfortunately, I was unlucky and didn't see a failure all the times I tested #994 before merging. Since that change broke Racket, I've taken the rare step of merging the first cut at this PR to Racket while it's pending here.

The implementation of eq?-based hashtables turns off interrupts, but the parameter setting had no effect on the checks now inserted for make-vector. An interrupt can go wrong with operations like hashtable-keys with weekly held keys, because keys could disappear before being transferred to a newly allocated vector.

The solution of not inserting an interrupt trap in make-vector when generate-interrupt-trap is #f seems like the obvious approach, but that interacts badly with wrappers for make-vector and similar as defined in "prims.ss". Instead, this commit adds a new procedure $make-vector/no-interrupt-trap. In general, functions that need to avoid interrupts must choose the functions they call carefully, anyway, and make-vector has become one that cannot be called.

The repaired operations $eq-hashtable-keys, etc., now use $make-vector/no-interrupt-trap, but they also use $use-trap-fuel after the result is created. The $eq-hashtable-copy and $eq-hashtable-clear operations similarly need $use-trap-fuel, and they previously did not use make-vector or another operation that would have inserted interrupt checks.

This commit repairs a problem created by the previous commit (cisco#994),
and it further repairs some hashtable operations alog the same lines
as vector operations in that commit.

The implementation of `eq?`-based hashtables turns off interrupts, but
the parameter setting had no effect on the checks now inserted for
`make-vector`. An interrupt can go wrong with operations like
`hashtable-keys` with weekly held keys, because keys could disappear
before being transferred to a newly allocated vector.

The solution of not inserting an interrupt trap in `make-vector` when
`generate-interrupt-trap` is `#f` seems like the obvious approach, but
that interacts badly with wrappers for `make-vector` and similar as
defined in "prims.ss". Instead, this commit adds a new procedure
`$make-vector/no-interrupt-trap`. In general, functions that need to
avoid interrupts must choose the functions they call carefully,
anyway, and `make-vector` has become one that cannot be called.

The repaired operations `$eq-hashtable-keys`, etc., now use
`$make-vector/no-interrupt-trap`, but they also use `$use-trap-fuel`
after the result is created. The `$eq-hashtable-copy` and
`$eq-hashtable-clear` operations similarly need `$use-trap-fuel`, and
they previously did not use `make-vector` or another operation that
would have inserted interrupt checks.
@mflatt mflatt merged commit 0db54f0 into cisco:main Dec 1, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants