Pointer aliasing issue results in miscompile on gcc4.4
| Bug #46311 | Pointer aliasing issue results in miscompile on gcc4.4 | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2008-10-16 03:16 UTC | Modified: | 2013-03-19 19:24 UTC |
|
||||||||||
| From: | anton at samba dot org | Assigned: | dmitry (profile) | |||||||||||
| Status: | Closed | Package: | Compile Failure | |||||||||||
| PHP Version: | 5.2.9 | OS: | RHEL5.2 / PowerPC64 | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2008-10-16 03:16 UTC] anton at samba dot org
Description:
------------
A recent checkout of gcc4.4 miscompiles php on PowerPC64. The following function reads from p via long * and stores to p via void * which violates aliasing rules:
static inline void zend_ptr_stack_clear_multiple(TSRMLS_D)
{
void **p = EG(argument_stack).top_element-2;
int delete_count = (int)(zend_uintptr_t) *p;
EG(argument_stack).top -= (delete_count+2);
while (--delete_count>=0) {
zval *q = *(zval **)(--p);
*p = NULL;
zval_ptr_dtor(&q);
}
EG(argument_stack).top_element = p;
}
More details can be found at:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37824
We can remove the (zval **) cast so that we read and write via void *p and fix the aliasing issue. I will attach a patch.
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2008-10-16 03:20 UTC] anton at samba dot org
[2008-10-16 05:54 UTC] anton at samba dot org
[2013-03-19 18:51 UTC] olemarkus@php.net
[2013-03-19 19:24 UTC] dmitry@php.net
[2013-08-22 07:34 UTC] olemarkus@php.net
[2013-08-22 09:06 UTC] nikic@php.net
-Status: Assigned +Status: Closed