vmware / splinterdb

High Performance Embedded Key-Value Store
https://splinterdb.org
Apache License 2.0
680 stars 57 forks source link

Segmentation fault after splinterdb_stats_reset() #546

Closed deukyeon closed 1 year ago

deukyeon commented 1 year ago

There is a bug that causes a segmentation fault when recording histograms again after calling splinterdb_stats_reset(), as shown in the gdb output:

Thread 30 "ycsbc" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffe8bbff640 (LWP 1843516)]
trunk_insert (spl=<optimized out>, tuple_key=..., data=...) at src/trunk.c:6188
6188                platform_histo_insert(spl->stats[tid].update_latency_histo,

The issue seems to be that the histogram is zeroed out in trunk_reset_stats(), which is called by splinterdb_stats_reset(), as shown below:

void
trunk_reset_stats(trunk_handle *spl)
{
   if (spl->cfg.use_stats) {
      memset(spl->stats, 0, MAX_THREADS * sizeof(trunk_stats));
   }
}