|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-05-30 18:03 UTC] aharvey@php.net
[2013-06-03 06:57 UTC] ab@php.net
[2013-06-03 18:52 UTC] dev at pp3345 dot net
[2013-06-03 19:06 UTC] pajoye@php.net
[2013-06-07 16:24 UTC] dev at pp3345 dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 18:00:01 2025 UTC |
Description: ------------ This is not quite a bug, rather a little annoyance for extension developers. See the following struct, defined in /main/SAPI.h on line 118: typedef struct _sapi_globals_struct { void *server_context; sapi_request_info request_info; sapi_headers_struct sapi_headers; int read_post_bytes; unsigned char headers_sent; struct stat global_stat; char *default_mimetype; char *default_charset; HashTable *rfc1867_uploaded_files; long post_max_size; int options; zend_bool sapi_started; double global_request_time; HashTable known_post_content_types; zval *callback_func; zend_fcall_info_cache fci_cache; zend_bool callback_run; } sapi_globals_struct; used for sapi_globals. All elements except global_stat will have the same size across different systems. When an extension tries to access elements that lie behind global_stat this can lead to problems (like segfaults) due to different compiled offsets. This is not a problem as long as the extension is compiled on the same system as PHP, however, for example closed-source extensions are distributed as precompiled binaries. In order to avoid problems due to different compiled offsets when trying to access sapi_globals I'd suggest placing global_stat at the end of the struct instead of the middle. This should not lead to any problems but will make life for extension developers easier since they don't have to invent ugly and probably buggy workarounds. For BC with already existing extensions I'd recommend patching this for PHP 5.5, but not for PHP 5.4. Extensions will have to be recompiled for 5.5 anyway. I know that some fancy compiler options for memory alignment will mess up the offsets within the struct too, but I think it's safe to assume that these are not common, especially since Zend itself seems to assume specific offsets in some places too.