Flash removal never decrements the query map entry count

Closed Beginner friendly
#649 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
83/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
backend

Research direction

Start with src/sys/session/flash.c:55-74 and src/sys/session/flash.c:164-175, where single removal and pop-all leave the count unchanged. Find the existing flash tests and add checks for counts after each operation and repeated set/remove cycles on an empty map. Done when removals keep the count accurate and empty-map reuse does not cause unnecessary bucket-array growth.

Written by the indexing model from the issue text.

Description

bug

Affected: dev at bb2a33946.

cwist_flash_get() unlinks and frees a bucket but never decrements req->flash->count (src/sys/session/flash.c:55-74). cwist_flash_pop_all_json() clears every bucket at src/sys/session/flash.c:164-175 and also leaves count unchanged.

Reproduced: after one set/get cycle, count_after_get=1; after serializing and clearing another entry, count_after_pop=2.

The stale count makes later inserts believe the map is populated. Repeated set/remove cycles can trigger unnecessary bucket-array growth even though the map is empty.

Expected: decrement count on single removal and reset it to zero after pop-all, then add tests for counts and repeated empty-map reuse.

Dominant language
C
Stars
16
Forks
7
Avg merge
4h 28m
Merged PRs (30d)
191

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from c4punks/CWIST

All issues in c4punks/CWIST

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.