microsoftarchive / redis

Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes
http://redis.io
Other
20.81k stars 5.37k forks source link

Stack overflow in jemalloc (x86 build) #470

Open rohahn opened 8 years ago

rohahn commented 8 years ago

I compiled the latest sources (ddb9987) with Visual Studio 2015 for x86 and set maxmemory to 1gb in the config file. On multiple systems I get random crashes caused by a stack overflow in jemalloc. A crash happens after some time (e.g. 1 hour), even with a completely empty database in idle mode, but running redis-benchmark.exe results in a faster crash. The problem occurs only with x86 builds so far, but on x86 and x64 systems (Windows 7 + Windows 10).

Extract from the callstack: redis-server.exe!je_malloc_tsd_malloc(unsigned int size) Line 16 redis-server.exe!je_arenas_tsd_get_wrapper() Line 638 redis-server.exe!je_arenas_tsd_get() Line 638 redis-server.exe!je_choose_arena(arena_s * arena) Line 753 redis-server.exe!je_arena_malloc(arena_s * arena, unsigned int size, bool zero, bool try_tcache) Line 960 redis-server.exe!je_malloc_tsd_malloc(unsigned int size) Line 16 redis-server.exe!je_arenas_tsd_get_wrapper() Line 638 redis-server.exe!je_arenas_tsd_get() Line 638 redis-server.exe!je_choose_arena(arena_s * arena) Line 753 redis-server.exe!je_arena_malloc(arena_s * arena, unsigned int size, bool zero, bool try_tcache) Line 960 redis-server.exe!je_malloc_tsd_malloc(unsigned int size) Line 16 redis-server.exe!je_arenas_tsd_get_wrapper() Line 638 redis-server.exe!je_arenas_tsd_get() Line 638 redis-server.exe!je_choose_arena(arena_s * arena) Line 753 redis-server.exe!je_arena_malloc(arena_s * arena, unsigned int size, bool zero, bool try_tcache) Line 960 redis-server.exe!je_malloc_tsd_malloc(unsigned int size) Line 16

Unfortunately I neither managed to understand the jemalloc code nor to disable it. Is any of the other allocators still supported on Windows?

enricogior commented 8 years ago

Hi @rohahn jemalloc hasn't been tested on x86, but you may try to replace it with dlmalloc: in the projects Configuration Properties, under C/C++ there are the Preprocessor Definitions, replace USE_JEMALLOC with USE_DLMALLOC. To do the replacement you can use the VS UI or just edit the .vcxproj files since they are plain text. You can also remove the project libjemalloc from the solution, and all the references to it. If changing the preprocessor definitions is not enough let me know, there might be some other things to change that I don't recall right now. Thank you.