ZF-7413: strpos() operations on objects cause segfaults

Issue Type: Bug Created: 2009-07-29T11:15:44.000+0000 Last Updated: 2009-08-07T12:16:54.000+0000 Status: Resolved Fix version(s): - 1.9.1 (11/Aug/09)

Reporter: Alex Adriaanse (alexadriaanse) Assignee: Thomas Weidner (thomas) Tags: - Zend_Locale

Related issues: Attachments: - zend_locale_strpos_fix.patch


It has come to my attention that Zend_Date() causes a segfault when you pass another Zend_Date object to its constructor. After some debugging I realized that this segfault is caused by Zend_Locale calling strpos() on that Zend_Date object in _prepareLocale().

I realize that this is probably really a PHP bug, but it seems cleaner if _prepareLocale() casts $locale to a string first before performing any string operations on it.

I was able to reproduce this by executing the following command:

<pre class="literal">
php -r 'require_once "Zend/Date.php"; $x = new Zend_Date(); $y = new Zend_Date($x);'

Note that I'm only able to reproduce this problem on one out of three servers I've tested this on. I was able to reproduce it under 32-bit Debian Linux 5.0. I was not able to reproduce it under 64-bit Debian Linux 4.0 or 5.0.

I am attaching a patch that will fix the segmentation fault by casting $locale to a string at an earlier point.


Posted by Thomas Weidner (thomas) on 2009-07-29T11:55:33.000+0000

Which PHP release are you using on Debian ?

Posted by Alex Adriaanse (alexadriaanse) on 2009-07-29T12:00:55.000+0000

5.2.9 on all three servers that I've tested. The PHP packages were provided by (the server that produced the segfault had the 5.2.9-0.dotdeb.2 packages installed).

Posted by Thomas Weidner (thomas) on 2009-07-30T14:48:21.000+0000

This seems to be the related PHP bug:

Posted by Thomas Weidner (thomas) on 2009-08-07T11:48:52.000+0000

The reason of this segfault seem to be the huge memory footprint used when initiating date objects.

Some performance increasements have been implemented which prevent that this error occurs in this place.

Still, ZF is not able to solve a PHP internal error. The given code should have worked even with the used memory.

Posted by Alex Adriaanse (alexadriaanse) on 2009-08-07T12:16:53.000+0000

Understood. But wouldn't it be cleaner to move the string cast up a few lines anyway? The workaround seems easy and clean.

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.