wbolster / plyvel

Plyvel, a fast and feature-rich Python interface to LevelDB
https://plyvel.readthedocs.io/
Other
530 stars 75 forks source link

import plyvel caused malloc_zone_unregister for OSX sierra #54

Closed eminarcissus closed 7 years ago

eminarcissus commented 7 years ago

Python(5404,0x7fffe58773c0) malloc: *\ malloc_zone_unregister() failed for 0x7fffe586d000

Don't know if it is leveldb's problem or cython's problem, seems like there are some changes in regards to malloc_default_zone, but plyvel only did used malloc cimport from clib, so don't know if any idea I could get this fixed.

Some additional issues linked to this issue. https://github.com/gperftools/gperftools/issues/827

wbolster commented 7 years ago

looks like something outside plyvel's control, indeed...

eminarcissus commented 7 years ago

It can be fixed to rebuild leveldb from google's official github with

diff --git a/build_detect_platform b/build_detect_platform
index f062993..d30665f 100755
--- a/build_detect_platform
+++ b/build_detect_platform
@@ -205,9 +205,9 @@ EOF
     $CXX $CXXFLAGS -x c++ - -o $CXXOUTPUT -ltcmalloc 2>/dev/null  <<EOF
       int main() {}
 EOF
-    if [ "$?" = 0 ]; then
-        PLATFORM_LIBS="$PLATFORM_LIBS -ltcmalloc"
-    fi
-    #if [ "$?" = 0 ]; then
-    #    PLATFORM_LIBS="$PLATFORM_LIBS -ltcmalloc"
-    #fi

   rm -f $CXXOUTPUT 2>/dev/null
  fi

After replaced the lib,reinstall plyvel and it works like a charm as before.

This will disable tcmalloc which will introduce the problem in sierra, hope this might help anyone who have the same problem

nnop commented 7 years ago

Such a simple fix. However, will it affect the functionality of leveldb?

eminarcissus commented 7 years ago

I guess yes, the problem roots from tcmalloc, which optimize the performance for memory allocation, but from my own experience I didn't get any noticeable delay after disable tcmalloc from the change.

hellysmile commented 7 years ago

Hello there, here is fixed version of brew Formula for leveldb https://gist.github.com/hellysmile/ffd665fb1bd1bf978bc99cb7f57250c9

brew uninstall leveldb && brew install leveldb.rb

eddiesmo commented 7 years ago

Thanks @hellysmile. This worked for me!

yshua5631 commented 7 years ago

Awesome, it works! Thanks @hellysmile .

ZHHJemotion commented 7 years ago

Thanks, @hellysmile . I downloaded it and installed it by using Terminal. It worked very well for me!