Page MenuHomePhabricator

Excimer segfaults when compiled in ZTS mode
Closed, ResolvedPublic

Description

Remi Collet reported that all tests fail with a segfault when Excimer is compiled in ZTS mode. I confirmed this.

Event Timeline

It's a bit comical given the amount of code devoted to supposedly supporting ZTS mode. Evidently I never got around to testing it.

The GCC manual says "When the address-of operator is applied to a thread-local variable, it is evaluated at run time and returns the address of the current thread’s instance of that variable. An address so obtained may be used by any thread. When a thread terminates, any pointers to thread-local variables in that thread become invalid." But &EG(vm_interrupt) is giving 0x3602 which can't be dereferenced even in the same thread. Maybe something about the macro or the attributes of the storage it references is confusing the compiler.

config.m4 was forcing the compiler option -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, but that option is broken for shared extensions due to some kind of dynamic linking issue. The assembly generated by gcc -S is correct, but _tsrm_ls_cache ends up at the wrong address.

Change 667970 had a related patch set uploaded (by Tim Starling; owner: Tim Starling):
[mediawiki/php/excimer@master] Fix segfault in ZTS mode

https://gerrit.wikimedia.org/r/667970

Change 667970 merged by jenkins-bot:
[mediawiki/php/excimer@master] Fix segfault in ZTS mode

https://gerrit.wikimedia.org/r/667970