Project

General

Profile

Actions

Bug #95171

closed

Concurrent requests might fail because of PHP threaded getenv/putenv implementation

Added by Robert Kärner about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
System/Bootstrap/Configuration
Start date:
2021-09-10
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

When concurrent requests are made to the backend, they have a good chance of failing (especially on Windows), because of PHP threaded getenv/putenv implementation.

This is because:

  1. The environment is per process. This means that two instances of PHP will share the same environment in a multithreaded server, rather than each using a unique one.
  2. The functions putenv() and getenv() are not required to be re-entrant or thread safe. What this means is that if two threads happen to call them at the same time (either on different cores, or from a context switch in the middle of the function), bad things can happen.
  3. putenv() (in C) takes a pointer and references the memory, rather than copying it (depending on implementation; on a Mac it does make a copy iirc, even though this violates the spec.) PHP keeps this around in a hash table, which is destroyed at the end of the request. This may cause the environment to be cleared while another thread is running and using it.

It causes the core not being able to access various environment variables like 'TYPO3_PATH_COMPOSER_ROOT'.
Since the latest deprecation of PackageStates.php in composer mode this is causing various issues all over the place.
I.e. if 'TYPO3_PATH_COMPOSER_ROOT' cannot be read (returning false), relative composer package paths cannot be expanded to absolute ones, resulting in:

  • Missing template exceptions in the BE
  • BE icons not loading
  • Missing site configuration
  • probably many more

The core should not rely on getenv() to get environment variables, and probably fall back to $_ENV.

More information and explanation can be found at:

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #94996: Drop PackageStates.php in Composer modeClosedHelmut Hummel2021-08-25

Actions
Related to TYPO3 Core - Bug #95237: Usage of Composer 2.1 runtime API while only requireing 2.0Closed2021-09-16

Actions
Actions

Also available in: Atom PDF