Title | Scheme interpreter table_set is wrong |
Status | closed |
Priority | nice |
Assigned user | Gareth Rees |
Organization | Ravenbrook |
Description | In the example Scheme interpreter, the functions for setting a key in a table (table_set and table_try_set) do not check for staleness in the case that the key was not found in the table. This is wrong: the key might already be in the table, but hashed under its old address. Adding the key under the hash for its new address results in the key being present twice in the table, violating the invariant for hash tables, and causing trouble at the next rehash. Here's an interaction illustrating the problem: > (define ht (make-eq-hashtable)) ht > (hashtable-set! ht 'a 1) > (gc) > (hashtable-set! ht 'a 2) > ht #[hashtable (a 2) (a 1)] At this point the hashtable incorrectly has two entries for the key 'a. > (gc) > (hashtable-ref ht 'a #f) Assertion failed: (b->key == NULL), function table_rehash, file scheme.c, line 932. |
Analysis | Add an isstale() test if the key is not found in the table. Make sure the documentation [1] [2] is updated. |
How found | inspection |
Evidence | [1] <http://www.ravenbrook.com/project/mps/...html#testing-dependencies-for-staleness >[2] < http://www.ravenbrook.com/project/mps/...guide/advanced.html#location-dependency > |
Created by | Gareth Rees |
Created on | 2014-05-27 15:14:24 |
Last modified by | Gareth Rees |
Last modified on | 2014-09-29 20:28:56 |
History | 2014-05-27 GDR Created. |
Change | Effect | Date | User | Description |
---|---|---|---|---|
187079 | closed | 2014-09-28 23:32:37 | Gareth Rees | Must test a key for staleness with respect to a location dependency before setting it (not just before looking it up or deleting it). |