# tsrm in CLI

- Thread: https://externals.io/message/31494
- Original archive: https://news-web.php.net/php.internals/31494
- Started by Stanislav Malyshev on 2007-08-08T19:13:45+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #31494 — Stanislav Malyshev — 2007-08-08T19:13:45+00:00

URL: https://externals.io/message/31494#31494

Hi!

I looked at CLI SAPI and found this code, around line 719:

#ifdef ZTS
	compiler_globals = ts_resource(compiler_globals_id);
	executor_globals = ts_resource(executor_globals_id);
	core_globals = ts_resource(core_globals_id);
	sapi_globals = ts_resource(sapi_globals_id);
	tsrm_ls = ts_resource(0);
#endif

	/* startup after we get the above ini override se we get things right */
	if (cli_sapi_module.startup(&cli_sapi_module)==FAILURE) {

The problem here is that compiler/executor globals are allocated in 
zend_startup, which is called from cli_sapi_module.startup. So what is 
actually in compiler_globals and executor_globals is either tsrm_ls if 
they are initialized to 0 or random crap if they aren't. Can anybody 
explain me where I'm wrong and why this code works?
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #31495 — Stanislav Malyshev — 2007-08-08T21:51:47+00:00

URL: https://externals.io/message/31494#31495 · In reply to: #31494

> The problem here is that compiler/executor globals are allocated in 
> zend_startup, which is called from cli_sapi_module.startup. So what is 
> actually in compiler_globals and executor_globals is either tsrm_ls if 
> they are initialized to 0 or random crap if they aren't. Can anybody 
> explain me where I'm wrong and why this code works?

After a bit more looking into it appears that this code just does 
nothing since compiler_globals pointer isn't used in ZTS mode. So I'm 
going to delete this code unless I hear objections to it.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com
