yahoo / mdbm

MDBM a very fast memory-mapped key/value store.
BSD 3-Clause "New" or "Revised" License
993 stars 111 forks source link

Fix segfault when storing large objects to lru cache #66

Closed mnagaya closed 8 years ago

mnagaya commented 8 years ago

In the following conditions, _alloclob variable is NULL.

yahoocla commented 8 years ago

CLA is valid!

areese commented 8 years ago

@mnagaya is it possible to add a test case for this? Thanks.

mnagaya commented 8 years ago

This is a test result before the fix.

$ gmake;gmake run-test_cache
true 

###### Running  test_cache ######

LD_LIBRARY_PATH=/home/mnagaya/mdbm/test/src/lib/object:  object/test_cache -tall -x test_cache.xml 
Writing unit test results to XML file (test_cache.xml).
Test [MdbmSmokeTest::initialSetup]: 0.0041 sec elapsed 
Test [MdbmSmokeTest::smoke_test_cache_01]: 0.0009 sec elapsed 
Test [MdbmSmokeTest::smoke_test_cache_02]: 0.0005 sec elapsed 
Test [MdbmSmokeTest::smoke_test_cache_03]: 0.0005 sec elapsed 
Test [MdbmSmokeTest::smoke_test_cache_04]: 0.0003 sec elapsed 
Test [MdbmSmokeTest::smoke_test_cache_05]: 0.0221 sec elapsed 
Test [MdbmSmokeTest::smoke_test_cache_07]: 0.0006 sec elapsed 
Test [MdbmSmokeTest::smoke_test_cache_08]: 0.0005 sec elapsed 
Test [MdbmSmokeTest::smoke_test_cache_09]: 0.0004 sec elapsed 
Test [MdbmSmokeTest::smoke_test_cache_10]: 0.0003 sec elapsed 
Test [MdbmSmokeTest::smoke_test_cache_11]: 0.0005 sec elapsed 
gmake: *** [run-test_cache] Segmentation fault
areese commented 8 years ago

Thanks for adding the test. It looks like the continues can cause an extra loop where ntries is larger than MAX_TRIES causing this.