Making changes to PG() (php_core_globals)

php.internals

Gwynne

20 years ago
The subject line gives a pretty good idea what this question is about. Yes, I'm well aware of the dangers of making core changes, and I'm only doing it to give myself a better idea what's going on inside :). In any case, here's the problem... One of the changes I tried to make is changing the type of the track_errors setting from zend_bool to long. It seems like a simple enough change: change the type in php_globals.h, update the INI setting in main.c, update the actual usage of the var in main.c, update my local INI file to use an integer value. But as soon as I did this, my test build started showing leaks from php_hash_environment() and a crash in php_module_shutdown()-
>php_shutdown_ticks()->zend_llist_destroy(). My only guess as to why
it was happening is that I didn't change a type or expected size somewhere, but for the life of me I can't figure out where my mistake was; I haven't seen a harcoded size where sizeof() should be or anything like that, after poring through main.c, php_variables.c, zend_globals.h, php_globals.h, and the like. I've reverted my source, but I'd still like to know: What did I miss? TSRM was on (--enable-maintainer-zts), as was --enable-debug, if that helps. I didn't try it without TSRM; if I can't do it thread-safely, then I'm not doing it right regardless. -- Gwynne, Daughter of the Code "This whole world is an asylum for the incurable."

Sara Golemon

20 years ago
Did you run `make clean` between making the change and running the build? Files containing PG(track_changes) aren't the only ones you need to change, every PG element past track_changes is now located at a different memory offset from the start of the structure. And if you happen to be running under ZTS, you may even be not allocating enough space for storage which'll result in overruns. -Sara ----- Original Message ----- From: "Gwynne" <gwynne@skytag.com> Newsgroups: php.internals To: <internals@lists.php.net> Sent: Wednesday, July 05, 2006 4:41 AM Subject: Making changes to PG() (php_core_globals)

Gwynne

20 years ago
On Jul 5, 2006, at 11:17 AM, Sara Golemon wrote:
> Did you run `make clean` between making the change and running the > build? > > Files containing PG(track_changes) aren't the only ones you need to > change, every PG element past track_changes is now located at a > different memory offset from the start of the structure. And if > you happen to be running under ZTS, you may even be not allocating > enough space for storage which'll result in overruns.
Ouch! I guess I earned my crashes on that one, huh? Not doing a make clean... that's right up there with writing = where you mean == :). Thanks for the heads-up; it worked this time. -- Gwynne, Daughter of the Code "This whole world is an asylum for the incurable."