FS#54711 - [jemalloc] cannot allocate memory in static TLS block

Attached to Project: Arch Linux
Opened by Kenny MacDermid (kenmacd) - Thursday, 06 July 2017, 00:43 GMT
Last edited by Toolybird (Toolybird) - Wednesday, 20 September 2023, 22:55 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Christian Hesse (eworm)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

Description:

I had to downgrade this package to continue running rocksdb which was being loaded by python-rocksdb.

The error I was getting was:

from ._rocksdb import *
ImportError: /usr/lib/libjemalloc.so.2: cannot allocate memory in static TLS block

This appears to be related to this issue:

https://github.com/jemalloc/jemalloc/issues/937

Downgrading from jemalloc-5.0.0-2-x86_64 to jemalloc-4.5.0-1-x86_64 fixed this issue.

Steps to reproduce:

Install rocksdb from AUR
pip install python-rocksdb
python -c 'import rocksdb'
This task depends upon

Closed by  Toolybird (Toolybird)
Wednesday, 20 September 2023, 22:55 GMT
Reason for closing:  Upstream
Additional comments about closing:  Old and stale. Fedora/Debian don't use "--disable-initial-exec-tls" nor should we. Apps dlopening jemalloc is an edge case anyway.
Comment by Christian Hesse (eworm) - Thursday, 06 July 2017, 15:01 GMT
The package jemalloc 5.0.0-2 is quite old. Please test latest version from [extra].
Comment by Kenny MacDermid (kenmacd) - Thursday, 06 July 2017, 22:30 GMT
Sorry, when I was writing this I just copied the version that was in my cache directory. I tested and am running 1:5.0.1-1.
Comment by Christian Hesse (eworm) - Monday, 10 July 2017, 09:33 GMT
Looks like we have another unresolved upstream issue then...
Can you report upstream, please?
Comment by Kenny MacDermid (kenmacd) - Tuesday, 11 July 2017, 15:47 GMT
Thanks. I opened this issue: https://github.com/jemalloc/jemalloc/issues/955.

I suspect this bug will come up with any packages that dynamically load jemalloc.
Comment by Jonny Barnes (jonnybarnes) - Thursday, 14 September 2017, 13:29 GMT
I’ve hit the same error message. I installed imagemgick-full from the aur. Then I ran pecl install imagick to install the php extension for imagemagick.

When loading php, it loaded imagick.so which tried to load libjemalloc.so.2 and give the TLS stack error message.

Downgrading jemalloc is a successful workaround.
Comment by Kristian LM (kristianlm) - Monday, 17 January 2022, 08:50 GMT
Hi,

I'm a bit confused as to what's happening here. I can't get Python's rocksdb to work:

```
klm@kc ~ ➤ pip install rocksdb
Defaulting to user installation because normal site-packages is not writeable
Collecting rocksdb
Downloading rocksdb-0.7.0.tar.gz (27 kB)
Requirement already satisfied: setuptools>=25 in /usr/lib/python3.10/site-packages (from rocksdb) (59.1.1)
Using legacy 'setup.py install' for rocksdb, since package 'wheel' is not installed.
Installing collected packages: rocksdb
Running setup.py install for rocksdb ... done
Successfully installed rocksdb-0.7.0
klm@kc ~ ➤ python 20s
Python 3.10.1 (main, Dec 18 2021, 23:53:45) [GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rocksdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/klm/.local/lib/python3.10/site-packages/rocksdb/__init__.py", line 1, in <module>
from ._rocksdb import *
ImportError: /usr/lib/libjemalloc.so.2: cannot allocate memory in static TLS block
>>>
```

I believe this was working before (way before 2017 when this issue was created). Could this commit from September be the cause?

https://github.com/archlinux/svntogit-packages/commit/52d5af7e914fa71f37741398d651013bacf4322a#diff-b9f413d26ce524388c207d66ccbc6e6140d0b33eb7cca912f6b45843c63232f1L23

I think the "disable-initial-exec-tls" configure flag needs to be there, but as the above commit suggests - it isn't:

```
klm@kc ~ ➤ /usr/bin/jemalloc-config --config 134s
--enable-autogen --prefix=/usr CC=clang 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection' LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now CXX=clang++ 'CXXFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS'
```

jemalloc 5.2.1-3 does have this flag set:

```
klm@kc ~ ➤ cat /var/cache/pacman/pkg/jemalloc-1:5.2.1-3-x86_64.pkg.tar.zst | zstd -d | grep -a -- --disable-initial-exec-tls
echo "--disable-initial-exec-tls --enable-autogen --prefix=/usr 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt' LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now CPPFLAGS=-D_FORTIFY_SOURCE=2 'CXXFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt'"

```
Comment by Buggy McBugFace (bugbot) - Tuesday, 08 August 2023, 19:11 GMT
This is an automated comment as this bug is open for more then 2 years. Please reply if you still experience this bug otherwise this issue will be closed after 1 month.

Loading...