Edit report at https://bugs.php.net/bug.php?id=64950&edit=1

 ID:                 64950
 Updated by:         ahar...@php.net
 Reported by:        dev at pp3345 dot net
 Summary:            Make life for extension developers just a little bit
                     easier
 Status:             Open
 Type:               Feature/Change Request
 Package:            *Compile Issues
 Operating System:   Linux
 PHP Version:        5.5.0RC2
 Block user comment: N
 Private report:     N

 New Comment:

Just as a note, without expressing any opinion on the suggestion itself: the 
API 
is well and truly frozen for 5.5, so this wouldn't be an option until the next 
version.


Previous Comments:
------------------------------------------------------------------------
[2013-05-30 17:55:10] dev at pp3345 dot net

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.



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64950&edit=1

Reply via email to