Intermittent hashmap unit test failure
A unit:gcc:sid:amd64
job failed for v9.20:
https://gitlab.isc.org/isc-projects/bind9/-/jobs/4597131
[==========] tests: Running 8 test(s).
[ RUN ] isc_hashmap_hash_zero_length
[ OK ] isc_hashmap_hash_zero_length
[ RUN ] isc_hashmap_case
[ OK ] isc_hashmap_case
[ RUN ] isc_hashmap_1_120
[ OK ] isc_hashmap_1_120
[ RUN ] isc_hashmap_6_1000
[ OK ] isc_hashmap_6_1000
[ RUN ] isc_hashmap_24_200000
[ OK ] isc_hashmap_24_200000
[ RUN ] isc_hashmap_1_48000
[ OK ] isc_hashmap_1_48000
[ RUN ] isc_hashmap_8_20000
[ OK ] isc_hashmap_8_20000
[ RUN ] isc_hashmap_iterator
seen[i]
[ LINE ] --- hashmap_test.c:304: error: Failure!
The relevant bit of code is:
281 /* erase odd */
282 memset(seen, 0, count * sizeof(seen[0]));
283 result = isc_hashmap_iter_first(iter);
284 while (result == ISC_R_SUCCESS) {
285 char key[16] = { 0 };
286 ptrdiff_t i;
287 const uint8_t *tkey = NULL;
288 test_node_t *v = NULL;
289
290 isc_hashmap_iter_current(iter, (void *)&v);
291 isc_hashmap_iter_currentkey(iter, &tkey);
292
293 i = v - nodes;
294 snprintf(key, 16, "%u", (unsigned int)i);
295 strlcat(key, " key of a raw hashmap!!", 16);
296 assert_memory_equal(key, tkey, 16);
297
298 if (i % 2 == 0) {
299 result = isc_hashmap_iter_delcurrent_next(iter);
300 } else {
301 result = isc_hashmap_iter_next(iter);
302 }
303
304 >>>> assert_false(seen[i]);
305 seen[i] = true;
306 }
307 assert_int_equal(result, ISC_R_NOMORE);
308 for (size_t i = 0; i < count; i++) {
309 assert_true(seen[i]);
310 }
I think this is the first time I see a hashmap_test
failure, so
opening an issue felt prudent.
There is a core dump available among the job artifacts, but it looks like a lot of important variables have been optimized out, so I'm not sure how easy it is going to be to get to the bottom of this. However, if there is any chance that the hashmap implementation has a flaw, we'd better at least try before this manifests as something even more confusing...