Skip to content

_tsrm_ls_cache resolution #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 23 commits into from
Closed

_tsrm_ls_cache resolution #13

wants to merge 23 commits into from

Conversation

arnaud-lb
Copy link
Owner

No description provided.

@arnaud-lb arnaud-lb force-pushed the static-opcache-tls branch from b27f9e2 to 6432c75 Compare June 24, 2025 14:06
…6, not as precision 0 (php#18912)

Like in other languages, and especially C where printf originates from,
a missing precision should be treated as a 0 precision.
Because the ADJ_PRECISION flag was not set, the double formatting code
resetted the precision to the default float precision of 6.
@arnaud-lb arnaud-lb force-pushed the static-opcache-tls branch from 6dd7300 to d09a3f2 Compare June 24, 2025 17:47
TimWolla and others added 21 commits June 24, 2025 20:14
This functionality is not part of the POSIX interface.

- On FreeBSD, the wait6 system call provides it
- On Linux, the raw waitid system call provides it (glibc does not)

close phpGH-15921
Also no need to reset the cache unconditionally in fetchAll().
* Switch to windows-2022 in CI

windows-2019 runner will be dropped by GitHub on 2025-06-30.

* xfail test cases that fail on windows-2022
When the array functions perform their operation in-place, the
`@refcount 1` annotation is wrong and causes a failure under
`ZEND_VERIFY_FUNC_INFO`.
The test file tests all functions that have the in-place optimization,
even those that didn't have the refcount annotation, just to prevent
future regressions.

Closes phpGH-18929.
* PHP-8.3:
  Fix RCN violations in array functions
* PHP-8.4:
  Fix RCN violations in array functions
This is a continuation of phpGH-18927 to fix CI for windows-2022
This is a continuation of phpGH-18927 to fix CI for windows-2022
* PHP-8.2:
  Fix CI for windows-2022
* PHP-8.3:
  Fix CI for windows-2022
* PHP-8.4:
  Fix CI for windows-2022
@arnaud-lb arnaud-lb force-pushed the static-opcache-tls branch from d09a3f2 to 78a89b1 Compare June 25, 2025 08:40
This fixes the following linker error:

    TLS transition from R_X86_64_TLSGD to R_X86_64_GOTTPOFF against
    `_tsrm_ls_cache' at 0x12fc3 in section `.text' failed"

The error arises from how we obtain information about the _tsrm_ls_cache TLS
variable for use in JIT'ed code:

Normally, TLS variables are resolved via linker relocations [1], which of course
can not be used in JIT'ed code. Therefore we emit the relocation in AOT code and
use the result in JIT.

Specifically we use a fragment of the "General Dynamic" code sequence described
in [1]. Using the full code sequence would give us the address of the variable
in the current thread. Therefore we only use a fragment that gives us the
variable's TLS index and offset.

When Opcache is statically linked into the binary, linkers attempt to relax
(rewrite) this code sequence into a more efficient one. However, this fails
because they will not recognize the code sequence.

We now take a different approach:

 * Emit the exact full code sequence expected by linkers
 * Extract the TLS index/offset or TCB offset by inspecting the ASM code, rather
   than executing it (execution would give us the thread-local address).
 * This is done in a conservative way so that if the linker did
   something we didn't expect, we fallback to a safer (but slower) mechanism.

[1] https://www.akkadia.org/drepper/tls.pdf
@arnaud-lb arnaud-lb force-pushed the static-opcache-tls branch from 78a89b1 to 3700f9d Compare June 25, 2025 09:01
@arnaud-lb arnaud-lb closed this Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants