[PHP-BUG] Bug #65591 [NEW]: Segfault when calling parent::serialize in serialize().

2013-08-30 Thread arjen at react dot com
From: arjen at react dot com
Operating system: Linux
PHP version:  5.4Git-2013-08-30 (Git)
Package:  Reproducible crash
Bug Type: Bug
Bug description:Segfault when calling parent::serialize in serialize().

Description:

>From https://bugs.php.net/bug.php?id=63481&edit=3
Created new issue cause it's different from original bugreport.

See 
https://gist.github.com/aurelijus/4713758

Crashes 5.4.0 - 5.5.3: http://3v4l.org/PBT99

Test script:
---
id));
}
public function unserialize($serialized)
{
list($this->id) = unserialize($serialized);
}
 
}
 
class UserPermission implements \Serializable {
public $permission;
public $webshop;
 
public function serialize()
{
return serialize(array($this->webshop, $this->permission));
}
public function unserialize($serialized)
{
list($this->webshop, $this->permission) =
unserialize($serialized);
}
}
 
class Webshop  implements \Serializable {
protected $id = 13;
public function serialize()
{
return serialize(array($this->id));
}
public function unserialize($serialized)
{
list($this->id) = unserialize($serialized);
}
 
}
 
class AbstractToken  implements \Serializable {
public $roles;
 
public function serialize()
{
return serialize(array($this->roles));
}
public function unserialize($serialized)
{
list($this->roles) = unserialize($serialized);
}
 
}
class UsernamePasswordToken extends AbstractToken {
private $credentials = null;
private $providerKey = null;
 
public function serialize()
{
return serialize(array($this->credentials, $this->providerKey,
parent::serialize()));
}
 
public function unserialize($str)
{
list($this->credentials, $this->providerKey, $parentStr) =
unserialize($str);
parent::unserialize($parentStr);
}
}
 
$token = new UsernamePasswordToken();
$webshop = new Webshop;
$permission = new Permission;
$roles = array();
for ($i = 0; $i < 2; $i++) {
$roles[$i] = new UserPermission();
$roles[$i]->webshop = $webshop;
$roles[$i]->permission = $permission;
}
$token->roles = $roles;
var_dump(unserialize(serialize($token)));

Actual result:
--
segfault
Backtrace @ https://gist.github.com/anonymous/5720464

-- 
Edit bug report at https://bugs.php.net/bug.php?id=65591&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65591&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=65591&r=trysnapshot53
Try a snapshot (trunk): 
https://bugs.php.net/fix.php?id=65591&r=trysnapshottrunk
Fixed in SVN:   https://bugs.php.net/fix.php?id=65591&r=fixed
Fixed in release:   https://bugs.php.net/fix.php?id=65591&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65591&r=needtrace
Need Reproduce Script:  https://bugs.php.net/fix.php?id=65591&r=needscript
Try newer version:  https://bugs.php.net/fix.php?id=65591&r=oldversion
Not developer issue:https://bugs.php.net/fix.php?id=65591&r=support
Expected behavior:  https://bugs.php.net/fix.php?id=65591&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=65591&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=65591&r=submittedtwice
register_globals:   https://bugs.php.net/fix.php?id=65591&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65591&r=php4
Daylight Savings:   https://bugs.php.net/fix.php?id=65591&r=dst
IIS Stability:  https://bugs.php.net/fix.php?id=65591&r=isapi
Install GNU Sed:https://bugs.php.net/fix.php?id=65591&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65591&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65591&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65591&r=mysqlcfg



Bug #63481 [Com]: Segmentation fault caused by unserialize()

2013-08-30 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=63481&edit=1

 ID: 63481
 Comment by: arjen at react dot com
 Reported by:aurelijus at astdev dot lt
 Summary:Segmentation fault caused by unserialize()
 Status: Assigned
 Type:   Bug
 Package:Reproducible crash
 Operating System:   RHEL 6 & Mac OS X 10.7.4
 PHP Version:5.4.8
 Assigned To:mike
 Block user comment: N
 Private report: N

 New Comment:

Thanx!

The testcase in the original bugreport by aurelijus at astdev dot lt is also 
fixed on 5.4.20, don't know by which commit.

Create new issue for calling 'parent::serialize()' issue, which still crashes: 
https://bugs.php.net/bug.php?id=65591

This issues can be closed.


Previous Comments:

[2013-08-19 22:13:10] m...@php.net

See bug #65481


[2013-07-29 18:11:56] m...@php.net

Yes, please. I already have a possible fix for the second issue.


[2013-06-06 09:57:11] arjen at react dot com

I believe these are different issues, the backtrace is quite different.

Got the following results using php-5.4.15 from php.net:

Original report: https://gist.github.com/anonymous/5720457
Backtrace of https://gist.github.com/aurelijus/4713758: 
https://gist.github.com/anonymous/5720464

I tried reducing the original testcase, got a segfault but again the backtrace 
is quite different.

Testscript http://3v4l.org/3WCpP (crashes >= 5.4.0)
Backtrace at https://gist.github.com/anonymous/5720491

Should I create a seperate issue for it?


[2013-03-08 15:44:18] zach dot quintana at gmail dot com

I'm also experiencing a similar bug, but will unserializing a class that 
doesn't 
implement serializable. Need the code?


[2013-02-06 10:07:49] m...@php.net

Yep, avoiding parent::serialize() helps:

diff --git a/serialize.php b/serialize.php
index 14ae4c8..4def326 100644
--- a/serialize.php
+++ b/serialize.php
@@ -58,13 +58,12 @@ class UsernamePasswordToken extends AbstractToken {
 
 public function serialize()
 {
-return serialize(array($this->credentials, $this->providerKey, 
parent::serialize()));
+return serialize(array($this->credentials, $this->providerKey, $this-
>roles));
 }
 
 public function unserialize($str)
 {
-list($this->credentials, $this->providerKey, $parentStr) = 
unserialize($str);
-parent::unserialize($parentStr);
+list($this->credentials, $this->providerKey, $this->roles) = 
unserialize($str);
 }
 }




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=63481


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


Bug #65369 [Com]: Segfault when restarting Apache while script running with custom Exception

2013-08-30 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=65369&edit=1

 ID: 65369
 Comment by: arjen at react dot com
 Reported by:steve dot kehlet at gmail dot com
 Summary:Segfault when restarting Apache while script running
 with custom Exception
 Status: Open
 Type:   Bug
 Package:Reproducible crash
 Operating System:   CentOS 5.x
 PHP Version:5.5Git-2013-07-31 (snap)
 Block user comment: N
 Private report: N

 New Comment:

Related to/duplicate of #65463?


Previous Comments:

[2013-08-01 05:10:05] yohg...@php.net

Just a note.
It does not happen with cli.


[2013-07-31 20:50:49] steve dot kehlet at gmail dot com

Description:

Using php-trunk-201307311830, when I restart Apache while a PHP script is still 
running that has defined a subclass of Exception, it results in a segfault.


'./configure' '--prefix=/opt/php' '--with-apxs2=/opt/apache/bin/apxs' '--with-
ldap' '--enable-soap' '--enable-sockets=shared' '--with-pgsql=/opt/pgsql' 
'--with-
pdo-pgsql=/opt/pgsql' '--with-mysql' '--with-pdo-mysql' '--with-gd' 
'--with-jpeg-
dir' '--with-png-dir' '--with-zlib-dir' '--with-freetype-dir' 
'--enable-gd-native-
ttf' '--enable-pcntl' '--with-openssl' '--with-curl=/opt/curl' 
'--enable-mbstring' 
'--with-mcrypt'

# ./httpd -V
Server version: Apache/2.4.6 (Unix)
Server built:   Jul 30 2013 17:40:00
Server's Module Magic Number: 20120211:23
Server loaded:  APR 1.4.8, APR-UTIL 1.5.2
Compiled using: APR 1.4.8, APR-UTIL 1.5.2
Architecture:   64-bit
Server MPM: prefork
  threaded: no
forked: yes (variable process count)
Server compiled with
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/opt/apache"
 -D SUEXEC_BIN="/opt/apache/bin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"


# diff php.ini-production php.ini
378c378
< expose_php = On
---
> expose_php = Off


Test script:
---
http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) attach 15715
Attaching to process 15715
Reading symbols from /opt/apache/bin/httpd...done.
Reading symbols from /opt/pcre/lib/libpcre.so.1...done.
Loaded symbols for /opt/pcre/lib/libpcre.so.1
Reading symbols from /opt/apache/lib/libaprutil-1.so.0...done.
Loaded symbols for /opt/apache/lib/libaprutil-1.so.0
Reading symbols from /lib64/libexpat.so.0...(no debugging symbols found)...done.
Loaded symbols for /lib64/libexpat.so.0
Reading symbols from /opt/apache/lib/libapr-1.so.0...done.
Loaded symbols for /opt/apache/lib/libapr-1.so.0
Reading symbols from /lib64/libuuid.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libuuid.so.1
Reading symbols from /lib64/librt.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/librt.so.1
Reading symbols from /lib64/libcrypt.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libcrypt.so.1
Reading symbols from /lib64/libpthread.so.0...(no debugging symbols 
found)...done.
[Thread debugging using libthread_db enabled]
Loaded symbols for /lib64/libpthread.so.0
Reading symbols from /lib64/libdl.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/libdl.so.2
Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libc.so.6
Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols 
found)...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
Reading symbols from /lib64/libnss_files.so.2...(no debugging symbols 
found)...done.
Loaded symbols for /lib64/libnss_files.so.2
Reading symbols from /opt/apache/modules/mod_authn_file.so...done.
Loaded symbols for /opt/apache/modules/mod_authn_file.so
Reading symbols from /opt/apache/modules/mod_authn_core.so...done.
Loaded symbols for /opt/apache/modules/mod_authn_core.

Bug #64896 [Com]: Segfault with gc_collect_cycles using unserialize on certain objects

2013-08-30 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=64896&edit=1

 ID: 64896
 Comment by: arjen at react dot com
 Reported by:mark dot chong at acquireap dot com
 Summary:Segfault with gc_collect_cycles using unserialize on
 certain objects
 Status: Open
 Type:   Bug
 Package:Reproducible crash
 Operating System:   ubuntu
 PHP Version:5.4.15
 Block user comment: N
 Private report: N

 New Comment:

Still crashes 5.4-git, testscript attached.


Previous Comments:

[2013-06-11 21:56:47] webm4st0r at gmail dot com

I believe I am hitting a similar issue to this through running some test 
suites. 
I've not yet been able to get a smaller script to reproduce the problem, though 
the one in this issue does fail to run.

I have tested this on 5.4.16 on 64bit CentOS 6. I would be interested in 
testing 
a patch for this to determine if it truly is the same problem, as the crash I'm 
seeing in the test run is during php_request_shutdown, sometimes within a 
gc_collect_cycles, sometimes within a destroy_zend_class.

I am unable to reproduce these failures with zend.enable_gc = 0, or in a debug 
build.

I can provide some stack traces for both failures I've seen if that would be 
useful in looking into this.


[2013-06-05 13:32:34] larue...@php.net

Ha, I can reproduce this with non-debug build now. thanks


[2013-06-05 11:18:22] arjen at react dot com

I can confirm the segfault using PHP-5.4.15 build from php.net sources.

Backtrace is same as above @ https://gist.github.com/anonymous/5713123
Valgrind trace @ https://gist.github.com/anonymous/5713183


[2013-05-30 21:17:17] sjon at hortensius dot net

@laruence I can reproduce this easily, see http://3v4l.org/Z9Bg7#v545 every 
version of PHP since 5.4.5 segfaults on the script (without xdebug)

here is your backtrace without xdebug:

#0  0x00608737 in ?? ()
#1  0x0061f349 in _zval_ptr_dtor ()
#2  0x0063b8d8 in zend_hash_destroy ()
#3  0x0062d37b in _zval_dtor_func ()
#4  0x0069e31d in ?? ()
#5  0x0065508f in execute ()
#6  0x00621190 in zend_call_function ()
#7  0x00644e55 in zend_call_method ()
#8  0x0064eab2 in zend_objects_destroy_object ()
#9  0x0064c9a8 in gc_collect_cycles ()
#10 0x0063e699 in ?? ()
#11 0x006d6d6c in ?? ()
#12 0x0065508f in execute ()
#13 0x0062fb94 in zend_execute_scripts ()
#14 0x005d1afc in php_execute_script ()
#15 0x006d8d1f in ?? ()
#16 0x0042615d in ?? ()
#17 0x7690fa15 in __libc_start_main () from /usr/lib/libc.so.6
#18 0x004261f9 in _start ()

With a debug-build; this problem seems unreproducable


[2013-05-24 13:23:43] larue...@php.net

please disable xdebug then try again




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=64896


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


[PHP-BUG] Bug #65593 [NEW]: Segfault when calling ob_start from output buffering callback.

2013-08-30 Thread arjen at react dot com
From: arjen at react dot com
Operating system: Linux
PHP version:  5.4Git-2013-08-30 (Git)
Package:  Reproducible crash
Bug Type: Bug
Bug description:Segfault when calling ob_start from output buffering callback.

Description:

Unfortunately no easy to further reduce the testscript.
You have to run it using php -e to be able to reproduce it consistently.
However, 
it IS possible to generate without -e.

And yes, calling ob_start from output buffer handler is stupid. We found
this by 
accident :-)

Test script:
---
https://gist.github.com/arjenschol/6389030#file-testscript

Expected result:

No segfault, just the fatal error.

Actual result:
--
See https://gist.github.com/arjenschol/6389030 for a backtrace.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=65593&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65593&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=65593&r=trysnapshot53
Try a snapshot (trunk): 
https://bugs.php.net/fix.php?id=65593&r=trysnapshottrunk
Fixed in SVN:   https://bugs.php.net/fix.php?id=65593&r=fixed
Fixed in release:   https://bugs.php.net/fix.php?id=65593&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65593&r=needtrace
Need Reproduce Script:  https://bugs.php.net/fix.php?id=65593&r=needscript
Try newer version:  https://bugs.php.net/fix.php?id=65593&r=oldversion
Not developer issue:https://bugs.php.net/fix.php?id=65593&r=support
Expected behavior:  https://bugs.php.net/fix.php?id=65593&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=65593&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=65593&r=submittedtwice
register_globals:   https://bugs.php.net/fix.php?id=65593&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65593&r=php4
Daylight Savings:   https://bugs.php.net/fix.php?id=65593&r=dst
IIS Stability:  https://bugs.php.net/fix.php?id=65593&r=isapi
Install GNU Sed:https://bugs.php.net/fix.php?id=65593&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65593&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65593&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65593&r=mysqlcfg



Bug #64893 [Com]: Crash due to dtor call happening after dtor shutdown

2013-10-04 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=64893&edit=1

 ID: 64893
 Comment by: arjen at react dot com
 Reported by:ni...@php.net
 Summary:Crash due to dtor call happening after dtor shutdown
 Status: Open
 Type:   Bug
 Package:Scripting Engine problem
 PHP Version:5.5.0RC1
 Block user comment: N
 Private report: N

 New Comment:

The result '/home/nikic/dev/php-dev/Zend/zend_hash.c(946) : ht=0x42dea5c is 
already destroyed' only happens in a debug build.

In a normal build, a notice about a undefined variable $GLOBALS is generated: 
http://3v4l.org/jcBu6


Previous Comments:

[2013-05-21 22:42:59] ni...@php.net

Description:

If an object is created *after* the destructor shutdown, its dtor will be 
called when it is freed, which potentially happens during a phase of the 
shutdown process where the executor is no longer in a consistent state.

The test script uses the ob callback (called after dtor shutdown) to create an 
object and bind it to to the error callback, which is later freed during 
zend_deactivate, as part of the executor shutdown.

Result:
/home/nikic/dev/php-dev/Zend/zend_hash.c(946) : ht=0x42dea5c is already 
destroyed

Test script:
---
https://bugs.php.net/bug.php?id=64893&edit=1


Bug #60701 [Com]: __toString() which stores $this reference triggers segfault (with fix!)

2012-04-02 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=60701&edit=1

 ID: 60701
 Comment by: arjen at react dot com
 Reported by:daan at react dot com
 Summary:__toString() which stores $this reference triggers
 segfault (with fix!)
 Status: Assigned
 Type:   Bug
 Package:Reproducible crash
 Operating System:   CentOS
 PHP Version:5.3.8
 Assigned To:dmitry
 Block user comment: N
 Private report: N

 New Comment:

5.3.10 fixed the attached testcase, a more simple test now fails.

a = $this;
return 'waa?';
}
}

$a = new A;
echo trim($a);
echo trim($a->a);

Results:
5.3.0 - 5.3.9   waa?1
5.3.10 waa? Warning: trim() expects parameter 1 to be string, unknown given in 
/home/deployer/public_html/php/tmp/ba8096acaf18c52bc12e38619634c25b on line 14
5.4.0 Segmentationfault


Previous Comments:

[2012-03-26 09:05:57] s...@php.net

OK, I think I know what may be going on here. What you're getting as $this in 
toString() is not a real $object but a copy what was generated by 
SEPARATE_ZVAL_IF_NOT_REF() in parse_arg_object_to_string(). If you save this 
copy, there might be trouble since it'd be destroyed by writeobj and later 
cleanup of the function arguments. However, the patch proposed doesn't seem to 
solve the problem completely since $this->test variable is still corrupted in 
this scenario...


[2012-03-26 08:38:59] s...@php.net

I looked more into the code, and as far as I can see, the case where readobj == 
writeobj comes from parse_arg_object_to_string() - but there it is preceeded by 
SEPARATE_ZVAL_IF_NOT_REF(arg); so I don't see how you can get refcount > 1 
there 
unless you have IS_REF. Something else is going on there...


[2012-03-26 07:21:23] s...@php.net

I'm not sure I understand the patch, especially this part: 

if (readobj == writeobj) {
+   if (Z_REFCOUNT_P(readobj) <= 1) 
{
+   INIT_PZVAL(writeobj);
+   }
zval_dtor(readobj);

It looks like you initializing the object and then immediately calling dtor on 
it (since readobj == writeobj). Could you explain why and what you are trying 
to 
do there?


[2012-02-13 19:48:38] pada at hrz dot tu-chemnitz dot de

@sjon: Now, I retried with the original Test script from daan.
This patch works for me too, thanks :)


[2012-02-13 19:16:25] sjon at hortensius dot net

@andrew at localcoast dot net
Did you try to remove all __toString methods from your application? If that 
didn't fix it you are experiencing another bug and will probably need to 
generate 
a small reproducing script yourself

@pada at hrz dot tu-chemnitz dot de

your problem has nothing to do with this bug, You are simply demonstrating a 
recursive loop.




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=60701


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


[PHP-BUG] Bug #64916 [NEW]: finfo testcase contains copyrighted music.

2013-05-24 Thread arjen at react dot com
From: arjen at react dot com
Operating system: 
PHP version:  5.4Git-2013-05-24 (Git)
Package:  Unknown/Other Function
Bug Type: Bug
Bug description:finfo testcase contains copyrighted music.

Description:

While fixing #64830, a testcase with a MP3 testfile was added to the
repository.
The MP3 file contains the song Brother (unplugged) from Alice in chains.
(see
https://github.com/php/php-src/tree/PHP-5.4/ext/fileinfo/tests/resources)

We ran into the same issue with a file in our tests, this is a small audio
sample 
("scorchio!" from The Fast Show). While this is still copyrighted material,
a 
sub-second sample is probably less problematic than a full 4:27 song..

I could supply this file as alternative for the Alice in chains song, or it
could 
be replaced by any other free MP3 testfile.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=64916&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64916&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64916&r=trysnapshot53
Try a snapshot (trunk): 
https://bugs.php.net/fix.php?id=64916&r=trysnapshottrunk
Fixed in SVN:   https://bugs.php.net/fix.php?id=64916&r=fixed
Fixed in release:   https://bugs.php.net/fix.php?id=64916&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64916&r=needtrace
Need Reproduce Script:  https://bugs.php.net/fix.php?id=64916&r=needscript
Try newer version:  https://bugs.php.net/fix.php?id=64916&r=oldversion
Not developer issue:https://bugs.php.net/fix.php?id=64916&r=support
Expected behavior:  https://bugs.php.net/fix.php?id=64916&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=64916&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=64916&r=submittedtwice
register_globals:   https://bugs.php.net/fix.php?id=64916&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64916&r=php4
Daylight Savings:   https://bugs.php.net/fix.php?id=64916&r=dst
IIS Stability:  https://bugs.php.net/fix.php?id=64916&r=isapi
Install GNU Sed:https://bugs.php.net/fix.php?id=64916&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64916&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64916&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64916&r=mysqlcfg



[PHP-BUG] Bug #64960 [NEW]: Segfault in gc_zval_possible_root

2013-06-03 Thread arjen at react dot com
From: arjen at react dot com
Operating system: Archlinux
PHP version:  5.4.15
Package:  Scripting Engine problem
Bug Type: Bug
Bug description:Segfault in gc_zval_possible_root

Description:

Affects >= 5.3.0, including 5.4.16.

See http://3v4l.org/dTDPH#v536

Combination of custom exception handler and error handler, custom property
with a 
debug_backtrace defined to an exception and calling ob_end_clean while 
ob_end_flush was called.

Wasn't able to reduce this further.

Test script:
---
// this makes ob_end_clean raise an error
ob_end_flush();

class ExceptionHandler {
public function __invoke (Exception $e)
{
// this triggers the custom error handler
ob_end_clean();
}
}

// this must be a class, closure does not trigger segfault
set_exception_handler(new ExceptionHandler());

// exception must be throwed from error handler.
set_error_handler(function()
{
$e = new Exception;
$e->_trace = debug_backtrace();

throw $e;
});

// trigger error handler
$a['waa'];

Expected result:

No segfault.

Actual result:
--
#0  0x00648779 in gc_zval_possible_root ()
#1  0x00637168 in zend_hash_destroy ()
#2  0x00628c0b in _zval_dtor_func ()
#3  0x0061abd9 in _zval_ptr_dtor ()
#4  0x00637168 in zend_hash_destroy ()
#5  0x00628c0b in _zval_dtor_func ()
#6  0x0061abd9 in _zval_ptr_dtor ()
#7  0x0064a437 in zend_object_std_dtor ()
#8  0x0064a469 in zend_objects_free_object_storage ()
#9  0x0064fe16 in zend_objects_store_free_object_storage ()
#10 0x0061b123 in ?? ()
#11 0x00629bc2 in ?? ()
#12 0x005cc04d in php_request_shutdown ()
#13 0x00426004 in ?? ()
#14 0x7f9a6fddba15 in __libc_start_main () from /usr/lib/libc.so.6
#15 0x00426db9 in _start ()


-- 
Edit bug report at https://bugs.php.net/bug.php?id=64960&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64960&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64960&r=trysnapshot53
Try a snapshot (trunk): 
https://bugs.php.net/fix.php?id=64960&r=trysnapshottrunk
Fixed in SVN:   https://bugs.php.net/fix.php?id=64960&r=fixed
Fixed in release:   https://bugs.php.net/fix.php?id=64960&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64960&r=needtrace
Need Reproduce Script:  https://bugs.php.net/fix.php?id=64960&r=needscript
Try newer version:  https://bugs.php.net/fix.php?id=64960&r=oldversion
Not developer issue:https://bugs.php.net/fix.php?id=64960&r=support
Expected behavior:  https://bugs.php.net/fix.php?id=64960&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=64960&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=64960&r=submittedtwice
register_globals:   https://bugs.php.net/fix.php?id=64960&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64960&r=php4
Daylight Savings:   https://bugs.php.net/fix.php?id=64960&r=dst
IIS Stability:  https://bugs.php.net/fix.php?id=64960&r=isapi
Install GNU Sed:https://bugs.php.net/fix.php?id=64960&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64960&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64960&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64960&r=mysqlcfg



Bug #64960 [Com]: Segfault in gc_zval_possible_root

2013-06-04 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=64960&edit=1

 ID: 64960
 Comment by: arjen at react dot com
 Reported by:arjen at react dot com
 Summary:Segfault in gc_zval_possible_root
 Status: Open
 Type:   Bug
 Package:Scripting Engine problem
 Operating System:   Archlinux
 PHP Version:5.4.15
 Block user comment: N
 Private report: N

 New Comment:

Verified it's not an Archlinux issue:

~$ php -v
PHP 5.3.10-1ubuntu3.6 with Suhosin-Patch (cli) (built: Mar 11 2013 14:31:48) 

~$ php segfault.php 
PHP Notice:  ob_end_flush(): failed to delete and flush buffer. No buffer to 
delete or flush in /home/arjen/segfault.php on line 3
PHP Fatal error:  Uncaught exception 'Exception' in /home/arjen/segfault.php:19
Stack trace:
#0 [internal function]: {closure}(8, 'ob_end_clean():...', 
'/home/arjen/seg...', 
9, Array)
#1 /home/arjen/segfault.php(9): ob_end_clean()
#2 [internal function]: ExceptionHandler->__invoke(Object(Exception))
#3 {main}
  thrown in /home/arjen/segfault.php on line 19
Segmentation fault (core dumped)


Previous Comments:

[2013-06-04 15:28:15] larue...@php.net

I can not reproduce the "segfault"

--------------------
[2013-06-03 11:48:55] arjen at react dot com

Description:

Affects >= 5.3.0, including 5.4.16.

See http://3v4l.org/dTDPH#v536

Combination of custom exception handler and error handler, custom property with 
a 
debug_backtrace defined to an exception and calling ob_end_clean while 
ob_end_flush was called.

Wasn't able to reduce this further.

Test script:
---
// this makes ob_end_clean raise an error
ob_end_flush();

class ExceptionHandler {
public function __invoke (Exception $e)
{
// this triggers the custom error handler
ob_end_clean();
}
}

// this must be a class, closure does not trigger segfault
set_exception_handler(new ExceptionHandler());

// exception must be throwed from error handler.
set_error_handler(function()
{
$e = new Exception;
$e->_trace = debug_backtrace();

throw $e;
});

// trigger error handler
$a['waa'];

Expected result:

No segfault.

Actual result:
--
#0  0x00648779 in gc_zval_possible_root ()
#1  0x00637168 in zend_hash_destroy ()
#2  0x00628c0b in _zval_dtor_func ()
#3  0x0061abd9 in _zval_ptr_dtor ()
#4  0x00637168 in zend_hash_destroy ()
#5  0x00628c0b in _zval_dtor_func ()
#6  0x0061abd9 in _zval_ptr_dtor ()
#7  0x0064a437 in zend_object_std_dtor ()
#8  0x0064a469 in zend_objects_free_object_storage ()
#9  0x0064fe16 in zend_objects_store_free_object_storage ()
#10 0x0061b123 in ?? ()
#11 0x00629bc2 in ?? ()
#12 0x005cc04d in php_request_shutdown ()
#13 0x00426004 in ?? ()
#14 0x7f9a6fddba15 in __libc_start_main () from /usr/lib/libc.so.6
#15 0x00426db9 in _start ()







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


Bug #64960 [Fbk->Opn]: Segfault in gc_zval_possible_root

2013-06-05 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=64960&edit=1

 ID: 64960
 User updated by:arjen at react dot com
 Reported by:arjen at react dot com
 Summary:Segfault in gc_zval_possible_root
-Status: Feedback
+Status: Open
 Type:   Bug
 Package:Scripting Engine problem
 Operating System:   Archlinux
 PHP Version:5.4.15
 Block user comment: N
 Private report: N

 New Comment:

Centos 6.3 with Zend Server PHP (no Suhosin):

# php -v
PHP 5.3.14 (cli) (built: Jun 19 2012 03:47:42) 

Archlinux (from repo, no Suhosin)
$ php -v
PHP 5.4.15 (cli) (built: May 12 2013 13:11:23) 

Are you sure you're not testing with a debug build? The segfault does not 
happen 
in debug 
builds.


Previous Comments:

[2013-06-05 03:10:20] larue...@php.net

please disable Suhosin patch and try again.


[2013-06-04 19:25:14] arjen at react dot com

Verified it's not an Archlinux issue:

~$ php -v
PHP 5.3.10-1ubuntu3.6 with Suhosin-Patch (cli) (built: Mar 11 2013 14:31:48) 

~$ php segfault.php 
PHP Notice:  ob_end_flush(): failed to delete and flush buffer. No buffer to 
delete or flush in /home/arjen/segfault.php on line 3
PHP Fatal error:  Uncaught exception 'Exception' in /home/arjen/segfault.php:19
Stack trace:
#0 [internal function]: {closure}(8, 'ob_end_clean():...', 
'/home/arjen/seg...', 
9, Array)
#1 /home/arjen/segfault.php(9): ob_end_clean()
#2 [internal function]: ExceptionHandler->__invoke(Object(Exception))
#3 {main}
  thrown in /home/arjen/segfault.php on line 19
Segmentation fault (core dumped)


[2013-06-04 15:28:15] larue...@php.net

I can not reproduce the "segfault"

----------------
[2013-06-03 11:48:55] arjen at react dot com

Description:

Affects >= 5.3.0, including 5.4.16.

See http://3v4l.org/dTDPH#v536

Combination of custom exception handler and error handler, custom property with 
a 
debug_backtrace defined to an exception and calling ob_end_clean while 
ob_end_flush was called.

Wasn't able to reduce this further.

Test script:
---
// this makes ob_end_clean raise an error
ob_end_flush();

class ExceptionHandler {
public function __invoke (Exception $e)
{
// this triggers the custom error handler
ob_end_clean();
}
}

// this must be a class, closure does not trigger segfault
set_exception_handler(new ExceptionHandler());

// exception must be throwed from error handler.
set_error_handler(function()
{
$e = new Exception;
$e->_trace = debug_backtrace();

throw $e;
});

// trigger error handler
$a['waa'];

Expected result:

No segfault.

Actual result:
--
#0  0x00648779 in gc_zval_possible_root ()
#1  0x00637168 in zend_hash_destroy ()
#2  0x00628c0b in _zval_dtor_func ()
#3  0x0061abd9 in _zval_ptr_dtor ()
#4  0x00637168 in zend_hash_destroy ()
#5  0x00628c0b in _zval_dtor_func ()
#6  0x0061abd9 in _zval_ptr_dtor ()
#7  0x0064a437 in zend_object_std_dtor ()
#8  0x0064a469 in zend_objects_free_object_storage ()
#9  0x0064fe16 in zend_objects_store_free_object_storage ()
#10 0x0061b123 in ?? ()
#11 0x00629bc2 in ?? ()
#12 0x005cc04d in php_request_shutdown ()
#13 0x00426004 in ?? ()
#14 0x7f9a6fddba15 in __libc_start_main () from /usr/lib/libc.so.6
#15 0x00426db9 in _start ()







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


Bug #64960 [Com]: Segfault in gc_zval_possible_root

2013-06-05 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=64960&edit=1

 ID: 64960
 Comment by: arjen at react dot com
 Reported by:arjen at react dot com
 Summary:Segfault in gc_zval_possible_root
 Status: Open
 Type:   Bug
 Package:Scripting Engine problem
 Operating System:   Archlinux
 PHP Version:5.4.15
 Block user comment: N
 Private report: N

 New Comment:

Archlinux fetches src tarballs from http://www.php.net/downloads.php and does 
not apply any 
patch to the code. I tried the other versions to show it's not an Archlinux 
problem.

I manually verified by building it from src:

wget http://www.php.net/distributions/php-5.4.15.tar.gz
tar xf php-5.4.15.tar.gz
cd php-5.4.15
./configure
make

sapi/cli/php segfault.php

Fatal error: Uncaught exception 'Exception' in segfault.php:20
Stack trace:
#0 [internal function]: {closure}(8, 'ob_end_clean():...', 'segfault.php', 10, 
Array)
#1 segfault.php(10): ob_end_clean()
#2 [internal function]: ExceptionHandler->__invoke(Object(Exception))
#3 {main}
  thrown in segfault.php on line 20
Segmentation fault (core dumped)

sapi/cli/php -v
PHP 5.4.15 (cli) (built: Jun  5 2013 10:36:25) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

and again, when compiling from src (php.net tarball) with ./configure 
--enable-debug the 
segfault does not occur.


Previous Comments:

[2013-06-05 08:17:24] paj...@php.net

This is what we actually support:

http://www.php.net/downloads.php

or using:

https://github.com/php/php-src (use the 5.4 branch).

External patched versions like the one in ZendServer are not supported, while 
this possible bug may happen in these versions, we need to reproduce it with 
our 
code base.

------------
[2013-06-05 07:58:06] arjen at react dot com

Centos 6.3 with Zend Server PHP (no Suhosin):

# php -v
PHP 5.3.14 (cli) (built: Jun 19 2012 03:47:42) 

Archlinux (from repo, no Suhosin)
$ php -v
PHP 5.4.15 (cli) (built: May 12 2013 13:11:23) 

Are you sure you're not testing with a debug build? The segfault does not 
happen 
in debug 
builds.


[2013-06-05 03:10:20] larue...@php.net

please disable Suhosin patch and try again.

----------------
[2013-06-04 19:25:14] arjen at react dot com

Verified it's not an Archlinux issue:

~$ php -v
PHP 5.3.10-1ubuntu3.6 with Suhosin-Patch (cli) (built: Mar 11 2013 14:31:48) 

~$ php segfault.php 
PHP Notice:  ob_end_flush(): failed to delete and flush buffer. No buffer to 
delete or flush in /home/arjen/segfault.php on line 3
PHP Fatal error:  Uncaught exception 'Exception' in /home/arjen/segfault.php:19
Stack trace:
#0 [internal function]: {closure}(8, 'ob_end_clean():...', 
'/home/arjen/seg...', 
9, Array)
#1 /home/arjen/segfault.php(9): ob_end_clean()
#2 [internal function]: ExceptionHandler->__invoke(Object(Exception))
#3 {main}
  thrown in /home/arjen/segfault.php on line 19
Segmentation fault (core dumped)


[2013-06-04 15:28:15] larue...@php.net

I can not reproduce the "segfault"




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=64960


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


Bug #64896 [Com]: Segfault with gc_collect_cycles using unserialize on certain objects

2013-06-05 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=64896&edit=1

 ID: 64896
 Comment by: arjen at react dot com
 Reported by:mark dot chong at acquireap dot com
 Summary:Segfault with gc_collect_cycles using unserialize on
 certain objects
 Status: Open
 Type:   Bug
 Package:Reproducible crash
 Operating System:   ubuntu
 PHP Version:5.4.15
 Block user comment: N
 Private report: N

 New Comment:

I can confirm the segfault using PHP-5.4.15 build from php.net sources.

Backtrace is same as above @ https://gist.github.com/anonymous/5713123
Valgrind trace @ https://gist.github.com/anonymous/5713183


Previous Comments:

[2013-05-30 21:17:17] sjon at hortensius dot net

@laruence I can reproduce this easily, see http://3v4l.org/Z9Bg7#v545 every 
version of PHP since 5.4.5 segfaults on the script (without xdebug)

here is your backtrace without xdebug:

#0  0x00608737 in ?? ()
#1  0x0061f349 in _zval_ptr_dtor ()
#2  0x0063b8d8 in zend_hash_destroy ()
#3  0x0062d37b in _zval_dtor_func ()
#4  0x0069e31d in ?? ()
#5  0x0065508f in execute ()
#6  0x00621190 in zend_call_function ()
#7  0x00644e55 in zend_call_method ()
#8  0x0064eab2 in zend_objects_destroy_object ()
#9  0x0064c9a8 in gc_collect_cycles ()
#10 0x0063e699 in ?? ()
#11 0x006d6d6c in ?? ()
#12 0x0065508f in execute ()
#13 0x0062fb94 in zend_execute_scripts ()
#14 0x005d1afc in php_execute_script ()
#15 0x006d8d1f in ?? ()
#16 0x0042615d in ?? ()
#17 0x7690fa15 in __libc_start_main () from /usr/lib/libc.so.6
#18 0x004261f9 in _start ()

With a debug-build; this problem seems unreproducable


[2013-05-24 13:23:43] larue...@php.net

please disable xdebug then try again


[2013-05-24 01:21:08] edward dot savage at dodo dot com

With the given test case I get the segfault as described (Ubuntu 13.04/PHP 
5.4.9-4ubuntu2).  I found that I could work around it by adding a function like 
'usleep(1);' or '$var = 2;' between global and the $bar operation in the 
destructor.  A simple operation like '6^123;', even repeated at length, wasn't 
enough to avoid the fault.  

Once the test case was running without crashing I started looking at the array 
assignment to $bar.  I found that printing the result of $bar after the 
destructor ran showed that the values of $this->_private were lost from the 
global $bar.  Even more information is lost when gc_collect_cycles is executed. 
 It can be shown to only be the values as an assigned multidimensional array 
will retain its keys.  

This loss of data and the segfault can be avoided by moving the $bar assignment 
into a pseudo destructor or by removing the circular reference.  However, for 
the reported case there is definitely a data integrity issue when assigning an 
array to a global in a __destruct with a circular reference present.  I could 
not repeat this issue with other types of assignment like string and object.


[2013-05-22 08:42:45] mark dot chong at acquireap dot com

I have run the test case on 3 different machines which call caused a segfault, 
bellow is the bt from one of them

#0  _zend_mm_free_int (heap=0xe09290, p=0x77e793a8) at /tmp/buildd/php5-
5.4.15/Zend/zend_alloc.c:2100
#1  0x0068d97a in _zval_dtor (zvalue=) at 
/tmp/buildd/php5-5.4.15/Zend/zend_variables.h:35
#2  _zval_ptr_dtor (zval_ptr=0x77e779a0) at /tmp/buildd/php5-
5.4.15/Zend/zend_execute_API.c:438
#3  _zval_ptr_dtor (zval_ptr=0x77e779a0) at /tmp/buildd/php5-
5.4.15/Zend/zend_execute_API.c:427
#4  0x006aab38 in zend_hash_destroy (ht=0x77e778e0) at 
/tmp/buildd/php5-5.4.15/Zend/zend_hash.c:560
#5  0x0069b8fb in _zval_dtor_func (zvalue=0x7fffa5a0) at 
/tmp/buildd/php5-5.4.15/Zend/zend_variables.c:45
#6  0x00718e7d in zend_assign_to_variable (value=0x77e776d8, 
variable_ptr_ptr=0x77e40410) at /tmp/buildd/php5-
5.4.15/Zend/zend_execute.c:937
#7  ZEND_ASSIGN_SPEC_CV_VAR_HANDLER (execute_data=0x77e40378) at 
/tmp/buildd/php5-5.4.15/Zend/zend_vm_execute.h:33084
#8  0x006feaa7 in execute (op_array=0x77e76af0) at /tmp/buildd/php5-
5.4.15/Zend/zend_vm_execute.h:410
#9  0x7400fa81 in xdebug_execute (op_array=0x77e76af0) at 
/srv/debian_developer/xdebug/xdebug-2.2.1/build-php5/xdebug.c:1391
#10 0x0068f7e0 in zend_call_function (fci=fci@entry=0x7fffa970, 
fci_cache=0x77e73bb0, fci_cache@entry=0x7fffa940)
at /tmp/buildd/php5-5.4.15/Zend/zend_execute_API.c:958

Bug #60598 [Com]: cli/apache sapi segfault on objects manipulation

2013-06-05 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=60598&edit=1

 ID: 60598
 Comment by: arjen at react dot com
 Reported by:arekm at maven dot pl
 Summary:cli/apache sapi segfault on objects manipulation
 Status: Open
 Type:   Bug
 Package:Reproducible crash
 Operating System:   Linux
 PHP Version:5.4.0RC3
 Block user comment: N
 Private report: N

 New Comment:

Problem still present in php-5.4.15 verified from php.net src.

See https://gist.github.com/anonymous/5713352 for bt.


Previous Comments:

[2012-11-25 15:07:30] manuel-php at mausz dot at

Same on git master:
[object_properties_init]
  name=Object addr=2e3b42b0 pt_addr=2e3b6270
  pt[0]_addr=2e3b4dc8 pt[0].handle=#0
[zend_std_write_property]
  name=_guid (=pt[0])
  old_addr=2e3b4dc8 new_addr=2e3b42f8 new.handle=#0
[object_properties_init]
  name=Object addr=2e3b6688 pt_addr=2e3b6a60
  pt[0]_addr=2e3b4dc8 pt[0].handle=#0
[zend_std_write_property]
  name=_guid (=pt[0])
  old_addr=2e3b4dc8 new_addr=2e3b66d0 new.handle=#1
[zval_collect_white]
  adding zval to zval_to_free-list
  zval: addr=2e3b42f8 refcnt=2 handle=#0
[gc_collect_cycles]
  freeing zval
  zval: addr=2e3b42f8 refcnt=2 handle=#0
 ^^ - 1st zval free
[zend_object_std_dtor]
  object=Object addr=2e3b42b0 pt_addr=2e3b6270
  calling zval_ptr_dtor for pt[0]_addr=2e3b42f8 pt[0].refcnt=1515870810
   ^^ - 2nd zval free
pt[0].handle=#1515870810
[zend_object_std_dtor]
  object=Object addr=2e3b6688 pt_addr=2e3b6a60
  calling zval_ptr_dtor for pt[0]_addr=2e3b66d0 pt[0].refcnt=1 pt[0].handle=#1

Patch for my debug output:
https://gist.github.com/095e8dc10c3e18afb3e6

I recommend enabling ZEND_MM_HEAP_PROTECTION. This is why refcnt+handle is 
0x5a5a5a5a on 2nd free.


[2012-11-25 08:57:04] arekm at maven dot pl

Tested  http://snaps.php.net/php5.4-latest.tar.gz and still happens.

[arekm@ixion-pld ~/test/php5.4-201211250630]$ export LC_ALL=C
[arekm@ixion-pld ~/test/php5.4-201211250630]$ ./sapi/cli/php -n ./a.php
If you see this, try to increase OBJECT_COUNT to 100,000
zsh: segmentation fault  ./sapi/cli/php -n ./a.php
[arekm@ixion-pld ~/test/php5.4-201211250630]$ ./sapi/cli/php -n --version
PHP 5.5.0-dev (cli) (built: Nov 25 2012 09:37:34) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
[arekm@ixion-pld ~/test/php5.4-201211250630]$ gdb --args ./sapi/cli/php -n 
./a.php
GNU gdb (GDB) 7.4.50-0.20120120.2 (PLD Linux)
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pld-linux".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/users/arekm/test/php5.4-
201211250630/sapi/cli/php...done.
(gdb) r
Starting program: /home/users/arekm/test/php5.4-201211250630/sapi/cli/php -n 
./a.php
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
If you see this, try to increase OBJECT_COUNT to 100,000

Program received signal SIGSEGV, Segmentation fault.
0x006810d2 in gc_zval_possible_root (zv=0x77fabe78) at 
/home/users/arekm/test/php5.4-201211250630/Zend/zend_gc.c:143
143 GC_ZOBJ_CHECK_POSSIBLE_ROOT(zv);
(gdb) bt
#0  0x006810d2 in gc_zval_possible_root (zv=0x77fabe78) at 
/home/users/arekm/test/php5.4-201211250630/Zend/zend_gc.c:143
#1  0x00682ce7 in zend_object_std_dtor (object=0x77fabe48) at 
/home/users/arekm/test/php5.4-201211250630/Zend/zend_objects.c:54
#2  0x00682d19 in zend_objects_free_object_storage 
(object=0x77fabe48) at /home/users/arekm/test/php5.4-
201211250630/Zend/zend_objects.c:137
#3  0x00688398 in zend_objects_store_free_object_storage 
(objects=0xd0b260) at /home/users/arekm/test/php5.4-
201211250630/Zend/zend_objects_API.c:92
#4  0x00655003 in shutdown_executor () at /home/users/arekm/test/php5.4-
201211250630/Zend/zend_execute_API.c:297
#5  0x006632a6 in zend_deactivate () at /home/users/arekm/test/php5.4-
201211250630/Zend/zend.c:941
#6  0x006050bd in php_request_shutdown (dummy=dummy@entry=0x0) at 
/home/users/arekm/test/php5.4-201211250630/main/main.c:1781
#7  0x007072c4 in do_cli (argc=3, argv=0x7fffe968) at 
/home/users/arekm/test/php5.4-201211250630/sapi/cli/php_cli.c:1174
#8  0x00422925 in main (argc=3, argv=0x7fffe968) at 
/home/users/arekm/test

Bug #54350 [Com]: Memory corruption with user_filter

2013-06-05 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=54350&edit=1

 ID: 54350
 Comment by: arjen at react dot com
 Reported by:decoder-php at own-hero dot net
 Summary:Memory corruption with user_filter
 Status: Assigned
 Type:   Bug
 Package:Reproducible crash
 Operating System:   Linux x86-64
 PHP Version:5.3.6
 Assigned To:cataphract
 Block user comment: N
 Private report: N

 New Comment:

Also broken in 5.4.15: https://gist.github.com/anonymous/5713377


Previous Comments:

[2011-12-27 09:59:27] s...@php.net

Oops, wrong bug, sorry.


[2011-12-27 09:58:54] s...@php.net

Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.




[2011-04-02 03:04:30] cataphr...@php.net

Unfortunately this bug is just the tip of the iceberg. Resource management in 
the user filters has several problem. The oncreate and onclose methods also 
have problems and stack overflows can be caused by stream_filter_remove.

It's also possible that unsetting special properties such as .filter and 
.stream can cause problems.

I also don't see how these problems can be reliably fixed without modifying 
structures so this is going to be tough for PHP 5.3.


[2011-03-22 14:15:01] decoder-php at own-hero dot net

Description:

The attached code shows a serious memory corruption (either crash or abort by 
glibc). I think I reported a similar testcase before (using filter) but the 
crash/corruption seemed different and I think it was not user_filter related, 
so it's not clear if this is a duplicate or not.

Test script:
---
stream);
}
}
stream_filter_register('user_filter','user_filter');
$fd = fopen('php://memory','w');
$filter = stream_filter_append($fd, 'user_filter');
fwrite($fd, "foo");
?>

Actual result:
--
When run on command line, terminated by glibc:

*** glibc detected *** /home/decoder/LangFuzz/php-trunk/sapi/cli/php: 
munmap_chunk(): invalid pointer: 0x7fe4b1c7b420 ***

(+ backtraces)


When run in valgrind, the following happens (original testcase also segfaults 
here):

==10490== Invalid free() / delete / delete[]
==10490==at 0x4C270BD: free (vg_replace_malloc.c:366)
==10490==by 0x7C1211: zend_hash_del_key_or_index (zend_hash.c:521)
==10490==by 0x7E1511: zend_std_unset_property (zend_object_handlers.c:768)
==10490==by 0x700D8A: userfilter_filter (user_filters.c:262)
==10490==by 0x742495: _php_stream_write_filtered (streams.c:1072)
==10490==by 0x742630: _php_stream_write (streams.c:1138)
==10490==by 0x69F820: zif_fwrite (file.c:1225)
==10490==by 0x7ED653: zend_do_fcall_common_helper_SPEC 
(zend_vm_execute.h:638)
==10490==by 0x7F37D2: ZEND_DO_FCALL_SPEC_CONST_HANDLER 
(zend_vm_execute.h:1935)
==10490==by 0x7EC127: execute (zend_vm_execute.h:410)
==10490==by 0x7B0348: zend_execute_scripts (zend.c:1212)
==10490==by 0x726A6B: php_execute_script (main.c:2344)
==10490==  Address 0x6af28e8 is 256,808 bytes inside a block of size 262,144 
alloc'd
==10490==at 0x4C274A8: malloc (vg_replace_malloc.c:236)
==10490==by 0x778CBA: zend_mm_mem_malloc_alloc (zend_alloc.c:287)
==10490==by 0x77BB55: _zend_mm_alloc_int (zend_alloc.c:1971)
==10490==by 0x779B92: zend_mm_startup_ex (zend_alloc.c:1122)
==10490==by 0x779FBA: zend_mm_startup (zend_alloc.c:1217)
==10490==by 0x77DB2E: alloc_globals_ctor (zend_alloc.c:2640)
==10490==by 0x77DB45: start_memory_manager (zend_alloc.c:2656)
==10490==by 0x7AEF4A: zend_startup (zend.c:642)
==10490==by 0x725D5A: php_module_startup (main.c:1896)
==10490==by 0x8EAD7B: php_cli_startup (php_cli.c:414)
==10490==by 0x8EBB8A: main (php_cli.c:790)







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


Bug #60976 [Com]: PHP crashes sometimes while parsing

2013-06-05 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=60976&edit=1

 ID: 60976
 Comment by: arjen at react dot com
 Reported by:xrstf-misc at yahoo dot com
 Summary:PHP crashes sometimes while parsing
 Status: Open
 Type:   Bug
 Package:Reproducible crash
 Operating System:   Win7x64
 PHP Version:5.3.10
 Block user comment: N
 Private report: N

 New Comment:

Bug https://bugs.php.net/bug.php?id=48034 is about 8192 bytes long scripts.


Previous Comments:

[2012-03-13 19:42:42] pete dot walker at cap2 dot co dot uk

I'm also suffering from this issue. I had phpunit randomly crashing. Traced the 
problem using xdebug - I'm using the Database YAML extension 
(PHPUnit_Extensions_Database_DataSet_YamlDataSet), and it uses the include 
statement to load the YAML files.

The YAML file knocking everything over was exactly 8192 bytes long (and ended 
with whitespace, but not \n).


[2012-02-10 01:50:11] xrstf-misc at yahoo dot com

This is actually a good hint by hanssen at aeteurope dot nl: I too had some 
cases 
where a generated cache file (containing "" without trailing newline.

Inspection of lines 3181 and 3182 of Zend/zend_language_scanner.c reveals 
YYCURSOR being advanced one byte and a '\n' being expected, which fails here 
because it attempts to read memory beyond allocated memory.


[2012-02-06 17:23:08] giunta dot gaetano at gmail dot com

I also have php crashes - win7 64, apache 2.2.21 from apache lounge.
No error messages left in either php or apache logs - just a "server reset 
connection" error from the browser.
The code ran fine up to php 5.3.8 (did not test with 539).
It involves executing a custom page within eZPublish, it is hard for me to 
trace it to a single php file / command and attach it here...


[2012-02-05 15:19:32] xrstf-misc at yahoo dot com

Here is the original file, wrapped in an 7z archive:
http://www.xrstf.de/bug60976.7z (1KB)




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=60976


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


Bug #63481 [Com]: Segmentation fault caused by unserialize()

2013-06-06 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=63481&edit=1

 ID: 63481
 Comment by: arjen at react dot com
 Reported by:aurelijus at astdev dot lt
 Summary:Segmentation fault caused by unserialize()
 Status: Assigned
 Type:   Bug
 Package:Reproducible crash
 Operating System:   RHEL 6 & Mac OS X 10.7.4
 PHP Version:5.4.8
 Assigned To:mike
 Block user comment: N
 Private report: N

 New Comment:

I believe these are different issues, the backtrace is quite different.

Got the following results using php-5.4.15 from php.net:

Original report: https://gist.github.com/anonymous/5720457
Backtrace of https://gist.github.com/aurelijus/4713758: 
https://gist.github.com/anonymous/5720464

I tried reducing the original testcase, got a segfault but again the backtrace 
is quite different.

Testscript http://3v4l.org/3WCpP (crashes >= 5.4.0)
Backtrace at https://gist.github.com/anonymous/5720491

Should I create a seperate issue for it?


Previous Comments:

[2013-03-08 15:44:18] zach dot quintana at gmail dot com

I'm also experiencing a similar bug, but will unserializing a class that 
doesn't 
implement serializable. Need the code?


[2013-02-06 10:07:49] m...@php.net

Yep, avoiding parent::serialize() helps:

diff --git a/serialize.php b/serialize.php
index 14ae4c8..4def326 100644
--- a/serialize.php
+++ b/serialize.php
@@ -58,13 +58,12 @@ class UsernamePasswordToken extends AbstractToken {
 
 public function serialize()
 {
-return serialize(array($this->credentials, $this->providerKey, 
parent::serialize()));
+return serialize(array($this->credentials, $this->providerKey, $this-
>roles));
 }
 
 public function unserialize($str)
 {
-list($this->credentials, $this->providerKey, $parentStr) = 
unserialize($str);
-parent::unserialize($parentStr);
+list($this->credentials, $this->providerKey, $this->roles) = 
unserialize($str);
 }
 }


[2013-02-06 09:54:10] m...@php.net

Looks like an excellent test case.

I suspect the problem is calling parent::(un)serialize() within a 
(un)serialize() 
callback.

I'll try to find out.


[2013-02-05 12:00:29] aurelijus at astdev dot lt

Hi,
Here is a reproducible serialization/unserialization code
https://gist.github.com/aurelijus/4713758


[2012-11-12 12:29:29] aurelijus at astdev dot lt

It might have been another php process, it might have been the same.
1. generate $object.
2. serialize $object.
3. save $string in php session (under /tmp)
/* might be different process from here, it did not really matter, 
segmenatation 
fault happend in both cases */
4. get $string from session
5. dumped to a file for debugging (optional)
6. unserialize($string)
7. segmenatation fault.




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=63481


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


Bug #63516 [Com]: The Process exits random with SEGV

2013-06-07 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=63516&edit=1

 ID: 63516
 Comment by: arjen at react dot com
 Reported by:dpeuscher at gmail dot com
 Summary:The Process exits random with SEGV
 Status: Open
 Type:   Bug
 Package:SOAP related
 Operating System:   openSUSE 11.0 (X86-64)
 PHP Version:5.4.8
 Block user comment: N
 Private report: N

 New Comment:

Does not crash with WSDL_CACHE_DISK,
DOES crash with WSDL_CACHE_MEMORY.


Previous Comments:

[2013-06-06 15:59:48] dpeuscher at gmail dot com

Accidentally changed the package to apache2-related, sorry.


[2013-06-06 15:57:51] dpeuscher at gmail dot com

Have you tried the WSDL_CACHE_DISK caching method instead of WSDL_CACHE_BOTH?


[2013-06-06 11:25:48] arjen at react dot dom

I can confirm this under 5.4.15, got the same backtrace using the testscript.


[2012-11-15 14:16:07] dpeuscher at gmail dot com

That was a great hint. I got it isolated! It seams like the problem occurs when 
the ini-option wsdl_cache is set to 3 (WSDL_CACHE_BOTH), maybe also 2 
(WSDL_CACHE_MEMORY). I 
initialized 5 WSDL-Files that are nearly empty (just to don't throw any 
exceptions like "Could not find any usable binding services in WSDL.". They all 
look like this:

http://pastebin.com/e6QBUkeh (Wasn't allowed to put it in here because of 
possible Spam)

with 5 different names. I named them s1.wsdl, ... s5.wsdl. Afterwards I 
initialized an ebay-Webservice. The test-Script looks like this:

http://pastebin.com/dWxg1qL7

Sometimes the SEGV appears after 50 calls, sometimes on the first call. It 
doesn't apper on WSDL_CACHE_DISK or WSDL_CACHE_NONE.


[2012-11-15 00:00:05] fel...@php.net

Please, try isolating the SOAP related part of code.




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=63516


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


Bug #60701 [Com]: __toString() which stores $this reference triggers segfault (with fix!)

2012-04-26 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=60701&edit=1

 ID: 60701
 Comment by: arjen at react dot com
 Reported by:daan at react dot com
 Summary:__toString() which stores $this reference triggers
 segfault (with fix!)
 Status: Assigned
 Type:   Bug
 Package:Reproducible crash
 Operating System:   CentOS
 PHP Version:5.3.8
 Assigned To:dmitry
 Block user comment: N
 Private report: N

 New Comment:

5.3.10/5.4.0 fixed original testcase; see http://3v4l.org/sc0mQ
5.3.11/5.4.1 fixed modified testcase; see http://3v4l.org/iYBMZ

Please close this issue and mark as fixed!


Previous Comments:

[2012-04-02 09:53:08] arjen at react dot com

5.3.10 fixed the attached testcase, a more simple test now fails.

a = $this;
return 'waa?';
}
}

$a = new A;
echo trim($a);
echo trim($a->a);

Results:
5.3.0 - 5.3.9   waa?1
5.3.10 waa? Warning: trim() expects parameter 1 to be string, unknown given in 
/home/deployer/public_html/php/tmp/ba8096acaf18c52bc12e38619634c25b on line 14
5.4.0 Segmentationfault


[2012-03-26 09:05:57] s...@php.net

OK, I think I know what may be going on here. What you're getting as $this in 
toString() is not a real $object but a copy what was generated by 
SEPARATE_ZVAL_IF_NOT_REF() in parse_arg_object_to_string(). If you save this 
copy, there might be trouble since it'd be destroyed by writeobj and later 
cleanup of the function arguments. However, the patch proposed doesn't seem to 
solve the problem completely since $this->test variable is still corrupted in 
this scenario...


[2012-03-26 08:38:59] s...@php.net

I looked more into the code, and as far as I can see, the case where readobj == 
writeobj comes from parse_arg_object_to_string() - but there it is preceeded by 
SEPARATE_ZVAL_IF_NOT_REF(arg); so I don't see how you can get refcount > 1 
there 
unless you have IS_REF. Something else is going on there...


[2012-03-26 07:21:23] s...@php.net

I'm not sure I understand the patch, especially this part: 

if (readobj == writeobj) {
+   if (Z_REFCOUNT_P(readobj) <= 1) 
{
+   INIT_PZVAL(writeobj);
+   }
zval_dtor(readobj);

It looks like you initializing the object and then immediately calling dtor on 
it (since readobj == writeobj). Could you explain why and what you are trying 
to 
do there?


[2012-02-13 19:48:38] pada at hrz dot tu-chemnitz dot de

@sjon: Now, I retried with the original Test script from daan.
This patch works for me too, thanks :)




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=60701


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


Bug #61736 [Com]: warning in usort when calling debug_backtrace

2012-04-26 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=61736&edit=1

 ID: 61736
 Comment by: arjen at react dot com
 Reported by:hosiplan at gmail dot com
 Summary:warning in usort when calling debug_backtrace
 Status: Open
 Type:   Bug
 Package:Arrays related
 Operating System:   Linux
 PHP Version:5.4.1
 Block user comment: N
 Private report: N

 New Comment:

This worked in 5.3.0, it's broken in 5.3.1-5.3.11 and 5.4.0-5.4.1.

http://3v4l.org/1UiAq


Previous Comments:

[2012-04-16 08:17:11] hosiplan at gmail dot com

Affects version


[2012-04-15 12:27:13] hosiplan at gmail dot com

Description:

When I call a function debug_backtrace() in usort() callback, it triggers 
unrelated warning. 

When i var_dump() it's result, it's OK.


Verified on my mashine
$ php -v
PHP 5.3.11-dev (cli) (built: Mar  1 2012 16:31:39) 

and on my friend's mashine with 5.3.5

Test script:
---
https://bugs.php.net/bug.php?id=61736&edit=1


Bug #62084 [Com]: Segfault during inheritance check on method

2012-05-21 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=62084&edit=1

 ID: 62084
 Comment by: arjen at react dot com
 Reported by:victor dot kupriyanov at gmail dot com
 Summary:Segfault during inheritance check on method
 Status: Open
 Type:   Bug
 Package:Scripting Engine problem
 Operating System:   Any
 PHP Version:5.4.3
 Block user comment: N
 Private report: N

 New Comment:

5.2.0 - 5.2.17, 5.3.0 - 5.3.13 returns correct error.
5.4.0 - 5.4.3 generates segfault.

See http://3v4l.org/fMMr3


Previous Comments:

[2012-05-21 03:28:47] victor dot kupriyanov at gmail dot com

I can not reproduce the bug on custom build from the specified snapshot:


$ /tmp/php5.4/bin/php a.php
PHP Strict Standards:  Declaration of C::b() should be compatible with B::b(A 
$a) in /tmp/a.php on line 13

Strict Standards: Declaration of C::b() should be compatible with B::b(A $a) in 
/tmp/a.php on line 13
PHP Catchable fatal error:  Argument 1 passed to B::b() must be an instance of 
A, none given, called in /tmp/a.php on line 16 and defined in /tmp/a.php on 
line 
8

Catchable fatal error: Argument 1 passed to B::b() must be an instance of A, 
none given, called in /tmp/a.php on line 16 and defined in /tmp/a.php on line 8

$ /tmp/php5.4/bin/php -m
[PHP Modules]
apc
Core
ctype
date
dom
ereg
fileinfo
filter
hash
iconv
json
libxml
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter

[Zend Modules]

So you may assume it is fixed or invalid.


[2012-05-21 03:07:05] fel...@php.net

Please try using this snapshot:

  http://snaps.php.net/php5.4-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/




[2012-05-21 02:54:42] victor dot kupriyanov at gmail dot com

Ok, I disabled xdebug:

$ php -m
[PHP Modules]
apc
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
enchant
ereg
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
imagick
imap
intl
json
ldap
libxml
mbstring
mcrypt
mhash
mssql
mysql
mysqli
odbc
openssl
pcntl
pcre
PDO
pdo_dblib
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
pspell
readline
recode
Reflection
session
shmop
SimpleXML
snmp
soap
sockets
SPL
sqlite3
ssh2
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib

[Zend Modules]

Still got the same stacktrace:


$ gdb php
GNU gdb (GDB) Fedora (7.2-52.fc14)
...

(gdb) set args a.php
(gdb) r
Starting program: /usr/bin/php a.php
[Thread debugging using libthread_db enabled]
[New Thread 0x7fffe89f9700 (LWP 6709)]
[Thread 0x7fffe89f9700 (LWP 6709) exited]

Program received signal SIGSEGV, Segmentation fault.
zend_get_function_declaration (fptr=0x0) at /usr/src/debug/php-
5.4.3/Zend/zend_compile.c:3046
3046if (fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) {
(gdb) bt
#0  zend_get_function_declaration (fptr=0x0) at /usr/src/debug/php-
5.4.3/Zend/zend_compile.c:3046
#1  0x005a2479 in do_inheritance_check_on_method (child=0x77fc05e0, 
parent=0x77fc1000) at /usr/src/debug/php-5.4.3/Zend/zend_compile.c:3267
#2  0x005a2665 in do_inherit_method_check (child_function_table=, parent=, hash_key=, 
child_ce=
0x77fc0398) at /usr/src/debug/php-5.4.3/Zend/zend_compile.c:3288
#3  0x005d3cf1 in zend_hash_replace_checker_wrapper 
(target=0x77fc03c0, source=, pCopyConstructor=0x5a7bc0 
, size=240, 
pMergeSource=0x5a2620 , pParam=0x77fc0398) at 
/usr/src/debug/php-5.4.3/Zend/zend_hash.c:878
#4  zend_hash_merge_ex (target=0x77fc03c0, source=, 
pCopyConstructor=0x5a7bc0 , size=240, pMergeSource=
0x5a2620 , pParam=0x77fc0398) at 
/usr/src/debug/php-5.4.3/Zend/zend_hash.c:892
#5  0x005a850b in zend_do_inheritance (ce=0x77fc0398, 
parent_ce=0x77fc00e0) at /usr/src/debug/php-5.4.3/Zend/zend_compile.c:3519
#6  0x005a962c in do_bind_inherited_class (op_array=, opline=, class_table=0xdf4c30, 
parent_ce=0x77fc00e0, 
compile_time=1 '\001') at /usr/src/debug/php-5.4.3/Zend/zend_compile.c:4569
#7  0x005a985a in zend_do_early_binding () at /usr/src/debug/php-
5.4.3/Zend/zend_compile.c:4626
#8  0x0058c1ca in zendparse () at /usr/src/debug/php-
5.4.3/Zend/zend_language_parser.c:3547
#9  0x0058fa0d in compile_file (file_handle=0x7fffdec0, type=) at Zend/zend_language_scanner.l:579
#10 0x7fffeb906042 in phar_compile_file (file_handle=0x7fffdec0, 
type=8) 
at /usr/src/debug/php-5.4.3/ext/phar/phar.c:3391
#11 0x005c70ca in zend_execute_scripts (type=8, retval=0x0, 
file_count=3) at /usr/src/debug/php-5.4.3/Zend/zend.c:1264
#12 0x00566cc3 in php_execute_script (primary_file=0x7fffdec0) at 
/usr/src/debug/

Bug #62115 [Com]: Issue with method array_diff_assoc

2012-05-23 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=62115&edit=1

 ID: 62115
 Comment by: arjen at react dot com
 Reported by:patttern at gmail dot com
 Summary:Issue with method array_diff_assoc
 Status: Open
 Type:   Bug
 Package:Arrays related
 Operating System:   All
 PHP Version:5.4.3
 Block user comment: N
 Private report: N

 New Comment:

http://nl3.php.net/array_diff_assoc

"Two values from key => value pairs are considered equal only if (string) 
$elem1 === (string) $elem2 . In other words a strict check 
takes place so the string representations must be the same."

and 

"Note: This function only checks one dimension of a n-dimensional array. Of 
course you can check deeper dimensions by using, for 
example, array_diff_assoc($array1[0], $array2[0]);."

So values are casted to string for comparision.

The array-elements are casted to string, which results in "array". The 
following example returns no difference between the two arrays, 
while this is clearly not the case: http://3v4l.org/1LX4W#v540

Without notices, both arrays would look the same.  Notices are generated since 
5.4.0, which is a good solution IMO.


Previous Comments:

[2012-05-23 05:29:56] patttern at gmail dot com

Description:

While executing method array_diff_assoc error appears "Notice: Array to string 
conversion".
The output of script:
array(2) { ["one"]=> array(2) { ["param1"]=> string(23) "First Parameter for 
One" ["param2"]=> string(24) "Second Parameter for One" } ["two"]=> array(2) { 
["param1"]=> string(23) "First Parameter for Two" ["param2"]=> string(24) 
"Second Parameter for Two" } }
string(3) "two"
array(2) { ["param1"]=> string(23) "First Parameter for Two" ["param2"]=> 
string(24) "Second Parameter for Two" }
array(1) { ["two"]=> array(2) { ["param1"]=> string(23) "First Parameter for 
Two" ["param2"]=> string(24) "Second Parameter for Two" } }
Notice: Array to string conversion in /usr/web/data/test_array_diff.php on line 
14 Notice: Array to string conversion in /usr/web/data/test_array_diff.php on 
line 14 array(1) { ["one"]=> array(2) { ["param1"]=> string(23) "First 
Parameter 
for One" ["param2"]=> string(24) "Second Parameter for One" } }

What is wrong?

Test script:
---
 array ('param1' => 'First Parameter for One', 'param2' => 
'Second Parameter for One'),
'two' => array ('param1' => 'First Parameter for Two', 'param2' => 
'Second Parameter for Two')
);
$packages_from = $source_packages;
var_dump($packages_from); echo "\n";
$package_key = 'two';
var_dump($package_key); echo "\n";
$package_value = $source_packages[$package_key];
var_dump($package_value); echo "\n";
$packages_to = array($package_key => $package_value);
var_dump($packages_to); echo "\n";
$result_packages = array_diff_assoc($packages_from, $packages_to);
var_dump($result_packages); echo "\n";
?>







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


Bug #62115 [Com]: Issue with method array_diff_assoc

2012-05-25 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=62115&edit=1

 ID: 62115
 Comment by: arjen at react dot com
 Reported by:patttern at gmail dot com
 Summary:Issue with method array_diff_assoc
 Status: Not a bug
 Type:   Bug
 Package:Arrays related
 Operating System:   All
 PHP Version:5.4.3
 Block user comment: N
 Private report: N

 New Comment:

See http://nl3.php.net/manual/en/function.array-diff-assoc.php#73972


Previous Comments:

[2012-05-25 04:54:25] patttern at gmail dot com

Thank you for your answers!
For a test I run this script on different versions of PHP 

\n";
$source_packages = array(
'one' => array ('param1' => 'First Parameter for One', 'param2' => 
'Second Parameter for One'),
'two' => array ('param1' => 'First Parameter for Two', 'param2' => 
'Second Parameter for Two')
);
$packages_from = $source_packages;
var_dump($packages_from); echo "\n";
$package_key = 'two';
$package_value = $source_packages[$package_key];
$packages_to = array($package_key => $package_value);
var_dump($packages_to); echo "\n";
$result_packages = array_diff_assoc($packages_from, $packages_to);
var_dump($result_packages); echo "\n";
?>
===
PHP version: 5.3.10
array(2) { ["one"]=> array(2) { ["param1"]=> string(23) "First Parameter for 
One" ["param2"]=> string(24) "Second Parameter for One" } ["two"]=> array(2) { 
["param1"]=> string(23) "First Parameter for Two" ["param2"]=> string(24) 
"Second Parameter for Two" } }
array(1) { ["two"]=> array(2) { ["param1"]=> string(23) "First Parameter for 
Two" ["param2"]=> string(24) "Second Parameter for Two" } }
array(1) { ["one"]=> array(2) { ["param1"]=> string(23) "First Parameter for 
One" ["param2"]=> string(24) "Second Parameter for One" } } 
===
PHP version: 5.4.3
array(2) { ["one"]=> array(2) { ["param1"]=> string(23) "First Parameter for 
One" ["param2"]=> string(24) "Second Parameter for One" } ["two"]=> array(2) { 
["param1"]=> string(23) "First Parameter for Two" ["param2"]=> string(24) 
"Second Parameter for Two" } }
array(1) { ["two"]=> array(2) { ["param1"]=> string(23) "First Parameter for 
Two" ["param2"]=> string(24) "Second Parameter for Two" } }
Notice: Array to string conversion in /usr/web/data/test_array_diff.php on line 
13 Notice: Array to string conversion in /usr/web/data/test_array_diff.php on 
line 13 array(1) { ["one"]=> array(2) { ["param1"]=> string(23) "First 
Parameter 
for One" ["param2"]=> string(24) "Second Parameter for One" } }
===

Since 5.4+ version the work  of array_diff*  method changed. How I should 
rewrite this code to avoid errors? At the moment error log of a average visited 
site is increasing on 50+Mb every day because of this notice.

----------------
[2012-05-24 08:40:49] maar...@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

See the answer by arjen at react dot com.

The array_diff* methods aren't recursive. So you probably won't want to use 
them for multidimensional arrays, and thus it's an improvement that >= 5.4.0 
warns you.


[2012-05-23 13:38:56] arjen at react dot com

http://nl3.php.net/array_diff_assoc

"Two values from key => value pairs are considered equal only if (string) 
$elem1 === (string) $elem2 . In other words a strict check 
takes place so the string representations must be the same."

and 

"Note: This function only checks one dimension of a n-dimensional array. Of 
course you can check deeper dimensions by using, for 
example, array_diff_assoc($array1[0], $array2[0]);."

So values are casted to string for comparision.

The array-elements are casted to string, which results in "array". The 
following example returns no difference between the two arrays, 
while this is clearly not the case: http://3v4l.org/1LX4W#v540

Without notices, both arrays would look the same.  Notices

Req #61972 [Com]: addchild treats text as a tag

2012-05-25 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=61972&edit=1

 ID: 61972
 Comment by: arjen at react dot com
 Reported by:crashyn at op dot pl
 Summary:addchild treats text as a tag
 Status: Open
 Type:   Feature/Change Request
 Package:SimpleXML related
 Operating System:   Windows XP
 PHP Version:5.4.2
 Block user comment: N
 Private report: N

 New Comment:

Something is wrong here.
The tag is not removed, it's not encoded anymore. But &entity; are removed.
See  http://3v4l.org/EJGuL


Previous Comments:

[2012-05-25 11:54:40] sjon at hortensius dot net

Shouldn't the values passed to xmlNewChild in addChild go through BAD_CAST like 
all other Xml related methods do?


[2012-05-20 21:54:40] crashyn at op dot pl

";

$xml = new SimpleXMLElement($xml_header);
$xml->addChild("first_string","this is <mystring>");
$xml->addChild("second_string","this is < mystring>");
$xml->asXML("test.xml");
echo "" . $xml->first_string . "";   // 'this is '
echo $xml->second_string . "";// 'this is < mystring>'
?>


[2012-05-16 20:55:00] riptide dot tempora at opinehub dot com

Can you provide a test script and its actual vs. expected output to show 
exactly what you mean?


[2012-05-07 21:09:58] crashyn at op dot pl

Description:

---
>From manual page: http://www.php.net/simplexmlelement.addchild
---
addChild treats <my_string> as a tag nd removes it completely







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


Bug #61858 [Com]: DOMAttr debug info generates E_WARNING

2012-05-25 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=61858&edit=1

 ID: 61858
 Comment by: arjen at react dot com
 Reported by:sala...@php.net
 Summary:DOMAttr debug info generates E_WARNING
 Status: Open
 Type:   Bug
 Package:DOM XML related
 PHP Version:5.4.1
 Block user comment: N
 Private report: N

 New Comment:

In  5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.10, 5.4.0 not 
warning was generated, while both objects were printed as if the are empty.

In 5.3.11 - 5.3.13, 5.4.1 - 5.4.3 the content IS printed, AND a warning is 
generated.

http://3v4l.org/OcEGX


Previous Comments:

[2012-04-26 13:48:18] sala...@php.net

Description:

Trying var_dump()/print_r() a DOMAttr prints an E_WARNING message "Not yet 
implemented".

Test script:
---
loadXML('Test');

$example = $doc->getElementsByTagName('example')->item(0);
$attr= $example->getAttributeNode('a');

var_dump($attr);
print_r($attr);


Expected result:

object(DOMAttr)#2 (20) {
  ["name"]=>
  string(1) "a"
  ["specified"]=>
  bool(true)
  ["value"]=>
  string(1) "b"
  ["ownerElement"]=>
  string(22) "(object value omitted)"
  ["schemaTypeInfo"]=>
  NULL
  ["nodeName"]=>
  string(1) "a"
  ["nodeValue"]=>
  string(1) "b"
  ["nodeType"]=>
  int(2)
  ["parentNode"]=>
  string(22) "(object value omitted)"
  ["childNodes"]=>
  string(22) "(object value omitted)"
  ["firstChild"]=>
  string(22) "(object value omitted)"
  ["lastChild"]=>
  string(22) "(object value omitted)"
  ["previousSibling"]=>
  NULL
  ["attributes"]=>
  NULL
  ["ownerDocument"]=>
  string(22) "(object value omitted)"
  ["namespaceURI"]=>
  NULL
  ["prefix"]=>
  string(0) ""
  ["localName"]=>
  string(1) "a"
  ["baseURI"]=>
  string(1) "/"
  ["textContent"]=>
  string(1) "b"
}
DOMAttr Object
(
[name] => a
[specified] => 1
[value] => b
[ownerElement] => (object value omitted)
[schemaTypeInfo] => 
[nodeName] => a
[nodeValue] => b
[nodeType] => 2
[parentNode] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] => 
[attributes] => 
[ownerDocument] => (object value omitted)
[namespaceURI] => 
[prefix] => 
[localName] => a
[baseURI] => /
[textContent] => b
)


Actual result:
--
Warning: var_dump(): Not yet implemented in /tmp/php-OE78FO on line 9
object(DOMAttr)#2 (20) {
  ["name"]=>
  string(1) "a"
  ["specified"]=>
  bool(true)
  ["value"]=>
  string(1) "b"
  ["ownerElement"]=>
  string(22) "(object value omitted)"
  ["schemaTypeInfo"]=>
  NULL
  ["nodeName"]=>
  string(1) "a"
  ["nodeValue"]=>
  string(1) "b"
  ["nodeType"]=>
  int(2)
  ["parentNode"]=>
  string(22) "(object value omitted)"
  ["childNodes"]=>
  string(22) "(object value omitted)"
  ["firstChild"]=>
  string(22) "(object value omitted)"
  ["lastChild"]=>
  string(22) "(object value omitted)"
  ["previousSibling"]=>
  NULL
  ["attributes"]=>
  NULL
  ["ownerDocument"]=>
  string(22) "(object value omitted)"
  ["namespaceURI"]=>
  NULL
  ["prefix"]=>
  string(0) ""
  ["localName"]=>
  string(1) "a"
  ["baseURI"]=>
  string(1) "/"
  ["textContent"]=>
  string(1) "b"
}
DOMAttr Object

Warning: print_r(): Not yet implemented in /tmp/php-OE78FO on line 10
(
[name] => a
[specified] => 1
[value] => b
[ownerElement] => (object value omitted)
[schemaTypeInfo] => 
[nodeName] => a
[nodeValue] => b
[nodeType] => 2
[parentNode] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] => 
[attributes] => 
[ownerDocument] => (object value omitted)
[namespaceURI] => 
[prefix] => 
[localName] => a
[baseURI] => /
[textContent] => b
)







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


Bug #61537 [Com]: json_encode() incorrectly truncates/discards information

2012-06-20 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=61537&edit=1

 ID: 61537
 Comment by: arjen at react dot com
 Reported by:j...@php.net
 Summary:json_encode() incorrectly truncates/discards
 information
 Status: Re-Opened
 Type:   Bug
 Package:JSON related
 Operating System:   all
 PHP Version:5.4.0
 Assigned To:aharvey
 Block user comment: N
 Private report: N

 New Comment:

This fix was reverted on 5.4, but not for 5.3.14.
5.3.14 is now behaving different than 5.4.4: http://3v4l.org/eeXV2


Previous Comments:

[2012-05-02 07:11:50] s...@php.net

Automatic comment on behalf of stas
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=7bbd5521d28ee77c5a8df80174f52dad0112e872
Log: Revert "Fix bug #61537 (json_encode() incorrectly truncates/discards 
information) and"


[2012-05-02 07:10:34] s...@php.net

Sorry, the fix wasn't correct, had to revert it. Please correct the wrong 
things 
and reapply.


[2012-05-02 07:09:53] s...@php.net

Automatic comment on behalf of stas
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=7bbd5521d28ee77c5a8df80174f52dad0112e872
Log: Revert "Fix bug #61537 (json_encode() incorrectly truncates/discards 
information) and"


[2012-04-12 10:03:35] johan...@php.net

Automatic comment on behalf of a...@pwd.net.au
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=3f3ad30c50c32327e723046bcc6649d05dd9236a
Log: Fix bug #61537 (json_encode() incorrectly truncates/discards information) 
and remove a test case that's now mooted by this fix.


[2012-04-11 00:44:38] ahar...@php.net

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.






The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=61537


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


Req #62372 [Com]: crypt() and broken backwards compability in SHA rounds

2012-06-20 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=62372&edit=1

 ID: 62372
 Comment by: arjen at react dot com
 Reported by:jani dot ollikainen at mmd dot net
 Summary:crypt() and broken backwards compability in SHA
 rounds
 Status: Open
 Type:   Feature/Change Request
 Package:*Encryption and hash functions
 PHP Version:5.4.4
 Block user comment: N
 Private report: N

 New Comment:

Looks like PHP <= 5.1.7 has a limit on the saltstring of 9 chars.
If no $rounds is specified AND a salstring of 9 chars, all versions return the 
same hash: http://3v4l.org/nDiFd (2nd line, 1st line is with long hash).


Previous Comments:

[2012-06-20 11:44:29] jani dot ollikainen at mmd dot net

Tested with patched 5.4.4 where:
#define ROUNDS_MIN 1

HASH: 
$6$rounds=10$qNElXs2yMnL2.GNS3kiM7DqmGbFLdQfIwu2691aJgT3xgJazPLtw7RPKz3Dp8RIc4b5fmJ7qvlq/mPN8a.rE40
 - CRYPT: 
$6$rounds=10$qNElXs2yMnL2.GNS$YwaYQmhwsN2RzBImxlEjIL.0/YLlfYCDmyfozkCQWNKdKgZQtTpK3Y/TAw31deCnJrDzgrqpI6ckvJCBsoeNB/
NO MATCH

So problem isn't only in ROUNDS_MIN. Also I know that my hash hasn't $ after 
salt, but that's how PHP 5.1.6 creates it. Tested also with adding $ and result 
is similar:

HASH: 
$6$rounds=10$qNElXs2yMnL2.GNS$3kiM7DqmGbFLdQfIwu2691aJgT3xgJazPLtw7RPKz3Dp8RIc4b5fmJ7qvlq/mPN8a.rE40
 - CRYPT: 
$6$rounds=10$qNElXs2yMnL2.GNS$YwaYQmhwsN2RzBImxlEjIL.0/YLlfYCDmyfozkCQWNKdKgZQtTpK3Y/TAw31deCnJrDzgrqpI6ckvJCBsoeNB/
NO MATCH

So something else is also different...


[2012-06-20 10:58:38] jani dot ollikainen at mmd dot net

Description:

http://fi2.php.net/manual/en/function.crypt.php

"CRYPT_SHA512 - SHA-512 hash with a sixteen character salt prefixed with $6$. 
If the salt string starts with 'rounds=$', the numeric value of N is used to 
indicate how many times the hashing loop should be executed, much like the cost 
parameter on Blowfish. The default number of rounds is 5000, there is a minimum 
of 1000 and a maximum of 999,999,999. Any selection of N outside this range 
will be truncated to the nearest limit."

Why is that N put to minium of 1000? Now if I've made hash with old PHP (or 
with anything else) which has "$6$rounds=10$" I cannot check that, because if 
there's rounds mentioned PHP will do minimum of 1000 rounds and I get totally 
different hash to compare.

Sounds very nice! I can understant that rounds limit if I don't give salt to 
crypt(), but if I give a salt which has "$6$rounds=10$" it really should do 
just those 10 rounds!

Fails with:
PHP 5.4.4 (cli) (built: Jun 20 2012 13:48:48)
PHP 5.3.14 (cli) (built: Jun 20 2012 13:39:44)
PHP 5.3.3 (cli) (built: May  7 2012 19:58:17)

Works with:
PHP 5.1.6 (cli) (built: May  7 2012 15:03:06)


Test script:
---


Expected result:

HASH: 
$6$rounds=10$qNElXs2yMnL2.GNS3kiM7DqmGbFLdQfIwu2691aJgT3xgJazPLtw7RPKz3Dp8RIc4b5fmJ7qvlq/mPN8a.rE40
 - CRYPT: 
$6$rounds=10$qNElXs2yMnL2.GNS3kiM7DqmGbFLdQfIwu2691aJgT3xgJazPLtw7RPKz3Dp8RIc4b5fmJ7qvlq/mPN8a.rE40
MATCH OK


Actual result:
--
HASH: 
$6$rounds=10$qNElXs2yMnL2.GNS3kiM7DqmGbFLdQfIwu2691aJgT3xgJazPLtw7RPKz3Dp8RIc4b5fmJ7qvlq/mPN8a.rE40
 - CRYPT: 
$6$rounds=1000$qNElXs2yMnL2.GNS$/q7trYkbKkoJernsumbObt2IysdXGRx/ytFaG0HBC97rHHhYRQvUcyEuRHP6h5yj8V.fH7XKEw5hjofVmYONw1
NO MATCH







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


[PHP-BUG] Bug #60102 [NEW]: Incorrect behaviour when throwing an exception from __wakeup/autloading.

2011-10-20 Thread arjen at react dot com
From: 
Operating system: CentOS 5.6
PHP version:  5.3.8
Package:  *General Issues
Bug Type: Bug
Bug description:Incorrect behaviour when throwing an exception from 
__wakeup/autloading.

Description:

When unserializing an object Wakeup with an member b object which throws an

exception in __wakeup, the autoloading of member e of type e extends d
fails.

The thrown exception is also non-catchable.

Expected result:

loading Wakeup 
loaded Wakeup: 1
loading B 
loaded B: 1
loading E 
loading D 
loaded D: 1
loading E: 1
fail

Actual result:
--
loading Wakeup 
loaded Wakeup: 1
loading B 
loaded B: 1
loading E 
loading D 
loaded D: 1


Fatal error: Uncaught exception 'Exception' in testcase/B.php on line 5

-- 
Edit bug report at https://bugs.php.net/bug.php?id=60102&edit=1
-- 
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=60102&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=60102&r=trysnapshot53
Try a snapshot (trunk):  
https://bugs.php.net/fix.php?id=60102&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=60102&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=60102&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=60102&r=alreadyfixed
Need backtrace:  
https://bugs.php.net/fix.php?id=60102&r=needtrace
Need Reproduce Script:   
https://bugs.php.net/fix.php?id=60102&r=needscript
Try newer version:   
https://bugs.php.net/fix.php?id=60102&r=oldversion
Not developer issue: 
https://bugs.php.net/fix.php?id=60102&r=support
Expected behavior:   
https://bugs.php.net/fix.php?id=60102&r=notwrong
Not enough info: 
https://bugs.php.net/fix.php?id=60102&r=notenoughinfo
Submitted twice: 
https://bugs.php.net/fix.php?id=60102&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=60102&r=globals
PHP 4 support discontinued:  
https://bugs.php.net/fix.php?id=60102&r=php4
Daylight Savings:https://bugs.php.net/fix.php?id=60102&r=dst
IIS Stability:   
https://bugs.php.net/fix.php?id=60102&r=isapi
Install GNU Sed: 
https://bugs.php.net/fix.php?id=60102&r=gnused
Floating point limitations:  
https://bugs.php.net/fix.php?id=60102&r=float
No Zend Extensions:  
https://bugs.php.net/fix.php?id=60102&r=nozend
MySQL Configuration Error:   
https://bugs.php.net/fix.php?id=60102&r=mysqlcfg



Bug #60102 [Opn]: Incorrect behaviour when throwing an exception from __wakeup/autloading.

2011-10-20 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=60102&edit=1

 ID: 60102
 User updated by:arjen at react dot com
 Reported by:arjen at react dot com
 Summary:Incorrect behaviour when throwing an exception from
 __wakeup/autloading.
 Status: Open
 Type:   Bug
 Package:*General Issues
 Operating System:   CentOS 5.6
 PHP Version:5.3.8
 Block user comment: N
 Private report: N

 New Comment:

Testscript available @ http://home.react.com/~arjen/testcase.tar.gz
Because of multiple files.


Previous Comments:

[2011-10-20 11:57:20] arjen at react dot com

Description:

When unserializing an object Wakeup with an member b object which throws an 
exception in __wakeup, the autoloading of member e of type e extends d fails.

The thrown exception is also non-catchable.

Expected result:

loading Wakeup 
loaded Wakeup: 1
loading B 
loaded B: 1
loading E 
loading D 
loaded D: 1
loading E: 1
fail

Actual result:
--
loading Wakeup 
loaded Wakeup: 1
loading B 
loaded B: 1
loading E 
loading D 
loaded D: 1


Fatal error: Uncaught exception 'Exception' in testcase/B.php on line 5






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


[PHP-BUG] Bug #63512 [NEW]: parse_ini_file() with INI_SCANNER_RAW removes quotes from value.

2012-11-14 Thread arjen at react dot com
From: arjen at react dot com
Operating system: All
PHP version:  5.3.18
Package:  Filesystem function related
Bug Type: Bug
Bug description:parse_ini_file() with INI_SCANNER_RAW removes quotes from value.

Description:

An option value containing a constant followed by an quoted string is
transformed 
in constant string: CONSTANT "string" => CONSTANT string

This is broken since 5.3.15/5.4.5, probably by fixing 
https://bugs.php.net/bug.php?id=51094

See http://3v4l.org/VkQgF

And INI_SCANNER_RAW isn't really raw, as quotes are removed anyway.
For value = "string" I would expect array('value' => '"string"') as result,
so 
one can differentiate between value = "CONSTANT" and value = CONSTANT.

Test script:
---

  string(3) "123"
  ["constant"]=>
  string(12) "INSTALL_ROOT"
  ["quotedString"]=>
  string(6) "string"
  ["a"]=>
  string(16) "INSTALL_ROOT waa"
  ["b"]=>
  string(12) "INSTALL_ROOT"
  ["c"]=>
  string(16) "waa INSTALL_ROOT"
  ["d"]=>
  string(25) "INSTALL_ROOT INSTALL_ROOT"
}

Actual result:
--
array(7) {
  ["int"]=>
  string(3) "123"
  ["constant"]=>
  string(12) "INSTALL_ROOT"
  ["quotedString"]=>
  string(6) "string"
  ["a"]=>
  string(18) "INSTALL_ROOT "waa""
  ["b"]=>
  string(12) "INSTALL_ROOT"
  ["c"]=>
  string(18) ""waa" INSTALL_ROOT"
  ["d"]=>
  string(27) "INSTALL_ROOT "INSTALL_ROOT""
}

even better:

array(7) {
  ["int"]=>
  string(3) "123"
  ["constant"]=>
  string(12) "INSTALL_ROOT"
  ["quotedString"]=>
  string(6) ""string""
  ["a"]=>
  string(18) "INSTALL_ROOT "waa""
  ["b"]=>
  string(12) "INSTALL_ROOT"
  ["c"]=>
  string(18) ""waa" INSTALL_ROOT"
  ["d"]=>
  string(27) "INSTALL_ROOT "INSTALL_ROOT""
}

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63512&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63512&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63512&r=trysnapshot53
Try a snapshot (trunk): 
https://bugs.php.net/fix.php?id=63512&r=trysnapshottrunk
Fixed in SVN:   https://bugs.php.net/fix.php?id=63512&r=fixed
Fixed in release:   https://bugs.php.net/fix.php?id=63512&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63512&r=needtrace
Need Reproduce Script:  https://bugs.php.net/fix.php?id=63512&r=needscript
Try newer version:  https://bugs.php.net/fix.php?id=63512&r=oldversion
Not developer issue:https://bugs.php.net/fix.php?id=63512&r=support
Expected behavior:  https://bugs.php.net/fix.php?id=63512&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=63512&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=63512&r=submittedtwice
register_globals:   https://bugs.php.net/fix.php?id=63512&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63512&r=php4
Daylight Savings:   https://bugs.php.net/fix.php?id=63512&r=dst
IIS Stability:  https://bugs.php.net/fix.php?id=63512&r=isapi
Install GNU Sed:https://bugs.php.net/fix.php?id=63512&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63512&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63512&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63512&r=mysqlcfg



Bug #63512 [Com]: parse_ini_file() with INI_SCANNER_RAW removes quotes from value.

2012-11-14 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=63512&edit=1

 ID: 63512
 Comment by: arjen at react dot com
 Reported by:arjen at react dot com
 Summary:parse_ini_file() with INI_SCANNER_RAW removes quotes
 from value.
 Status: Open
 Type:   Bug
 Package:Filesystem function related
 Operating System:   All
 PHP Version:5.3.18
 Block user comment: N
 Private report: N

 New Comment:

Warning: expected result and actual result are swapped! :o


Previous Comments:

[2012-11-14 11:53:41] arjen at react dot com

Description:

An option value containing a constant followed by an quoted string is 
transformed 
in constant string: CONSTANT "string" => CONSTANT string

This is broken since 5.3.15/5.4.5, probably by fixing 
https://bugs.php.net/bug.php?id=51094

See http://3v4l.org/VkQgF

And INI_SCANNER_RAW isn't really raw, as quotes are removed anyway.
For value = "string" I would expect array('value' => '"string"') as result, so 
one can differentiate between value = "CONSTANT" and value = CONSTANT.

Test script:
---

  string(3) "123"
  ["constant"]=>
  string(12) "INSTALL_ROOT"
  ["quotedString"]=>
  string(6) "string"
  ["a"]=>
  string(16) "INSTALL_ROOT waa"
  ["b"]=>
  string(12) "INSTALL_ROOT"
  ["c"]=>
  string(16) "waa INSTALL_ROOT"
  ["d"]=>
  string(25) "INSTALL_ROOT INSTALL_ROOT"
}

Actual result:
--
array(7) {
  ["int"]=>
  string(3) "123"
  ["constant"]=>
  string(12) "INSTALL_ROOT"
  ["quotedString"]=>
  string(6) "string"
  ["a"]=>
  string(18) "INSTALL_ROOT "waa""
  ["b"]=>
  string(12) "INSTALL_ROOT"
  ["c"]=>
  string(18) ""waa" INSTALL_ROOT"
  ["d"]=>
  string(27) "INSTALL_ROOT "INSTALL_ROOT""
}

even better:

array(7) {
  ["int"]=>
  string(3) "123"
  ["constant"]=>
  string(12) "INSTALL_ROOT"
  ["quotedString"]=>
  string(6) ""string""
  ["a"]=>
  string(18) "INSTALL_ROOT "waa""
  ["b"]=>
  string(12) "INSTALL_ROOT"
  ["c"]=>
  string(18) ""waa" INSTALL_ROOT"
  ["d"]=>
  string(27) "INSTALL_ROOT "INSTALL_ROOT""
}






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


Bug #63512 [Com]: parse_ini_file() with INI_SCANNER_RAW removes quotes from value.

2012-11-15 Thread arjen at react dot com
Edit report at https://bugs.php.net/bug.php?id=63512&edit=1

 ID: 63512
 Comment by: arjen at react dot com
 Reported by:arjen at react dot com
 Summary:parse_ini_file() with INI_SCANNER_RAW removes quotes
 from value.
 Status: Assigned
 Type:   Bug
 Package:Filesystem function related
 Operating System:   All
 PHP Version:5.3.18
 Assigned To:laruence
 Block user comment: N
 Private report: N

 New Comment:

With this patch, the old behaviour is restored. But the "eat leading and 
trailing quotes" does 
not make sense..

var_dump(parse_ini_string('waa = "string" CONSTANT "anotherString"', false, 
INI_SCANNER_RAW));

5.3.18 (wrong):
array(1) {
  ["waa"]=>
  string(29) "string CONSTANT anotherString"
}

with patch (behaviour like in versions < 5.3.15)

array(1) {
  ["waa"]=>
  string(29) "string" CONSTANT "anotherString"
}


Now string appears to be the constant, and CONSTANT a quoted string..

expected/better:
array(1) {
  ["waa"]=>
  string(29) ""string" CONSTANT "anotherString""
}

So IHMO remove this whole trim quotes thingy.


Previous Comments:

[2012-11-15 04:46:29] pierr...@php.net

The following patch has been added/updated:

Patch Name: 63512-v3.diff
Revision:   1352954789
URL:
https://bugs.php.net/patch-display.php?bug=63512&patch=63512-v3.diff&revision=1352954789


[2012-11-15 04:45:54] pierr...@php.net

I created a patch for this bug (which also fix #62884).

Could you make a quick code review before I commit it ? 

Thanks


[2012-11-15 04:12:53] pierr...@php.net

The following patch has been added/updated:

Patch Name: 63512-v2.diff
Revision:   1352952773
URL:
https://bugs.php.net/patch-display.php?bug=63512&patch=63512-v2.diff&revision=1352952773


[2012-11-14 15:19:00] larue...@php.net

pierrick, do you have time to look at this? thanks :)


[2012-11-14 12:14:29] arjen at react dot com

Warning: expected result and actual result are swapped! :o




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=63512


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