approach0 / search-engine

A math-aware search engine.
http://approach0.xyz
MIT License
346 stars 50 forks source link

buffer overflow error #38

Closed MeganJS closed 1 month ago

MeganJS commented 1 month ago

I'm trying to reproduce the Bpref scores according to the instructions in the README file. I'm running into the following error when I try to run searchd.out: opening index at: `../indexer/mnt-vdisk.img/' ... setup cache size: 0 MB buffer overflow detected : terminated Aborted

For reference, this is what my command looks like: ./run/searchd.out -i ../indexer/mnt-vdisk.img/ -c 0 -T

I'm using the ecir-2020 version of the code. Any advice or help is appreciated. Thanks!

w32zhong commented 1 month ago

Hi @MeganJS, have you tried build a debug binary, and use gdb to identify where is the overflow triggered?

To build a debug binary, modify this line to something like

CC := gcc -std=gnu99 -g 

and rebuild the project (make clean && make).

MeganJS commented 1 month ago

I was able to track the error down to line 220 of searchd.c: postlist_cache_set_limit(&indices.ci, cache_sz MB, 0);

Within this function call, the specific point that triggered the error was around lines 30-32 within the postlist_cache_fork function in postlist_cache.c: size_t size = cache->math_cache.limit_sz; cache->math_cache.limit_sz = size * 0.6f; res |= math_postlist_cache_add(&cache->math_cache, prefix_path);

I wasn't able to figure out the bug, so I switched to using the pya0 branch of search-engine instead. Thank you for responding and I hope this helps someone!

w32zhong commented 1 month ago

thanks for posting this info. From the code you pin point, I don't see any overflow possibility there. But I know that branch is very old and I acknowledge the code quality isn't great, but I might have fixed the memory issue since then. I hope pya0 branch works for you, if not, leave me a message again and I might share you a more updated version.