Investigate using -mtls-dialect=gnu2
On Ubuntu 22.04, building Memray with USE_MEMRAY_TLS_MODEL=0 results in a broken build, because TLS variables need to be created with malloc, which calls our malloc hook, which tries to access (and create) our TLS variables, resulting in an infinite loop and stack overflow. This problem is fairly unique to how Ubuntu is building its python3 interpreter, but we believe we can work around it by using the modern gnu2 TLS dialect instead.
Also if I recall correctly this only happens with the debug version of the interpreter no?
Related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113874
Closing as probably we are not going to do it