Lifetime of keys

Skip to first unread message

Robert Fleischman

Feb 24, 2017, 9:25:55 AM2/24/17
to Concurrency Kit
Simple question about key lifetime.

I do a:

ck_ht_set_spmc()  with new data.  It returns the old data that got replaced in the ck_ht_entry_t that was provided.

Can I immediately delete the "key" (MODE_BYTESTRING of course)?   My thought is:  I provided them, I allocated them, as long as I am not using them, I can delete them!

However, I noticed valgrind got upset about concurrent read's to those bytes after I deleted them:


> ==32338== Thread 11:
> ==32338== Invalid read of size 1
> ==32338==    at 0x4C30C09: __memcmp_sse4_1 (in /usr/lib/valgrind/
> ==32338==    by 0x4519A9: ck_ht_map_probe_rd (in ...)
> ==32338==    by 0x45237E: ck_ht_get_spmc (in ...)


It seems to me:

- I called "set_spmc()", it did the "replace" and returned to me the "old values"
- I cleaned those up with "delete/free"
- A later get_spmc() seems to be looking at that memory!!!

That seems bad/wrong.


Weird that valgrind only complains about 1 BYTE!

Is it confused?


Reply all
Reply to author
0 new messages