You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Take this bug report with a grain of salt, but when enabling mimalloc (note: not using it, just linking our .so with it) some of our CI builds fail deterministically with a "cannot allocate memory in static TLS block" error.
I also know that jemalloc faced a similar issue and provided a build-time option to work around it. It happens in the cases where jemalloc or the jemalloc-containing library (in case jemalloc was statically linked) is loaded lazily using dlopen. This seems to correspond exactly to the cases where we get the aforementioned error.
(amusingly, we were the ones reporting the jemalloc error already :-))
Darn, mimalloc has just 2 thread local variables, one for the default heap for that thread, and one for the recursion guard. I was hoping that would avoid this error. Is it possible for you try this with commenting out the static mi_decl_thread bool recurse = false; in options.c (just make it static for the test). I wonder if requiring just one slot makes a difference.
I am working currently also on fixing the TLS recursion guard on Apple (and some BSD) systems so perhaps I will add another way than requiring initial-exec. (Also, it seems building with -ftls-model=gnu2 instead of -ftls-model=initial-exec may work too.)
Activity
daanx commentedon Sep 3, 2019
Darn, mimalloc has just 2 thread local variables, one for the default heap for that thread, and one for the recursion guard. I was hoping that would avoid this error. Is it possible for you try this with commenting out the
static mi_decl_thread bool recurse = false;inoptions.c(just make it static for the test). I wonder if requiring just one slot makes a difference.I am working currently also on fixing the TLS recursion guard on Apple (and some BSD) systems so perhaps I will add another way than requiring initial-exec. (Also, it seems building with
-ftls-model=gnu2instead of-ftls-model=initial-execmay work too.)daanx commentedon Sep 3, 2019
Just wanted to add that using
-ftls-model=local-dynamicshould also work and seems to add almost no overhead; maybe 2% in my tests.pitrou commentedon Sep 3, 2019
It seems that
-ftls-model=local-dynamicwould fix the issue, at least according to my local tests.pitrou commentedon Sep 3, 2019
static bool recurse = false;doesn't seem to work, though (I still get the TLS-related error).pitrou commentedon Sep 3, 2019
And
gnu2isn't recognized here (gcc 7.4.0, Ubuntu 18.04):daanx commentedon Sep 4, 2019
Good to hear --
-ftls-model=local-dynamicseems the proper solution for this. Maybe we can make it a build option.Fix microsoft#147: provide CMake option for alternate TLS mechanism
pitrou commentedon Sep 4, 2019
I opened #148.
Merge pull request #148 from pitrou/tls-local-dynamic