php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67605 Segmentation fault Locale::getDisplayRegion
Submitted: 2014-07-11 06:26 UTC Modified: 2014-07-13 06:49 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: warnar at boekkooi dot net Assigned: stas (profile)
Status: Closed Package: intl (PECL)
PHP Version: 5.5.14 OS: Ubuntu 12.04
Private report: No CVE-ID: None
 [2014-07-11 06:26 UTC] warnar at boekkooi dot net
Description:
------------
Have a script that calls `Locale::getDisplayRegion` with the first argument being NULL.

Some system information about my system:
Packages installed from ppa:ondrej/php5:
php-apc						install
php5						install
php5-apcu					install
php5-cli					install
php5-common					install
php5-curl					install
php5-intl					install
php5-json					install
php5-mcrypt					install
php5-mysql					install
php5-readline					install
php5-xdebug					install

Version (php -v):
PHP 5.5.14-2+deb.sury.org~precise+1 (cli) (built: Jul  2 2014 12:07:02) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans

Intl information (from php -v):
intl

Internationalization support => enabled
version => 1.1.0
ICU version => 52.1
ICU Data version => 52.1

Directive => Local Value => Master Value
intl.default_locale => no value => no value
intl.error_level => 0 => 0
intl.use_exceptions => 0 => 0


Test script:
---------------
<?php
Locale::getDisplayRegion(null, "en_US");


Expected result:
----------------
A catch-able exception or NULL

Actual result:
--------------
Segmentation fault

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-11 06:36 UTC] warnar at boekkooi dot net
Quick update it also happens with any of the following lines:
Locale::getDisplayLanguage(null);
Locale::getDisplayName(null);
Locale::getDisplayRegion(null);
Locale::getDisplayScript(null);
Locale::getDisplayVariant(null);
 [2014-07-11 08:43 UTC] giggsey at gmail dot com
Able to reproduce on Ubuntu 14.10 (PHP 5.5.14-1~dotdeb.1 (cli) (built: Jun 29 2014 22:09:43)) and CentOS 6.5 (PHP 5.5.14 (cli) (built: Jun 27 2014 11:42:57) (from IUS Community)).

# php -v
PHP 5.5.14 (cli) (built: Jun 27 2014 11:42:57)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

# php -a
Interactive shell

php > Locale::getDisplayLanguage(null);
Segmentation fault

# gdb php
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1)
Copyright (C) 2010 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-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/php...Reading symbols from /usr/lib/debug/usr/bin/php.debug...done.
done.
(gdb) run localeNull.php
Starting program: /usr/bin/php localeNull.php
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff542d596 in __strcmp_sse42 () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff542d596 in __strcmp_sse42 () from /lib64/libc.so.6
#1  0x00007fffead00464 in findOffset (key=0x0, list=<value optimized out>)
    at /usr/src/debug/php-5.5.14/ext/intl/locale/locale_methods.c:113
#2  0x00007fffead00788 in get_icu_disp_value_src_php (
    tag_name=<value optimized out>, ht=1, return_value=0x7ffff7fd4e78,
    return_value_ptr=<value optimized out>, this_ptr=<value optimized out>,
    return_value_used=<value optimized out>)
    at /usr/src/debug/php-5.5.14/ext/intl/locale/locale_methods.c:514
#3  0x00000000005aa4f9 in dtrace_execute_internal (
    execute_data_ptr=<value optimized out>, fci=<value optimized out>,
    return_value_used=<value optimized out>)
    at /usr/src/debug/php-5.5.14/Zend/zend_dtrace.c:97
#4  0x000000000063c652 in zend_do_fcall_common_helper_SPEC (
    execute_data=<value optimized out>)
    at /usr/src/debug/php-5.5.14/Zend/zend_vm_execute.h:552
#5  0x000000000062e148 in execute_ex (execute_data=0x7ffff7fa2080)
    at /usr/src/debug/php-5.5.14/Zend/zend_vm_execute.h:363
#6  0x00000000005aa62e in dtrace_execute_ex (execute_data=0x7ffff7fa2080)
    at /usr/src/debug/php-5.5.14/Zend/zend_dtrace.c:73
#7  0x00000000005b949c in zend_execute_scripts (type=8, retval=0x0,
    file_count=3) at /usr/src/debug/php-5.5.14/Zend/zend.c:1316
#8  0x0000000000559bd0 in php_execute_script (primary_file=0x7fffffffd310)
    at /usr/src/debug/php-5.5.14/main/main.c:2506
#9  0x000000000066abd3 in do_cli (argc=2, argv=0x9c2af0)
    at /usr/src/debug/php-5.5.14/sapi/cli/php_cli.c:994
#10 0x000000000066b3d8 in main (argc=2, argv=0x9c2af0)
    at /usr/src/debug/php-5.5.14/sapi/cli/php_cli.c:1378
 [2014-07-11 21:32 UTC] stas@php.net
Can not reproduce in my 5.5 build.
 [2014-07-13 06:48 UTC] stas@php.net
Looks like this is the result of a bad merge. In 5.4, 5.5 etc. main branches, line 509 of ext/intl/locale/locale_methods.c looks like this:

        loc_name = intl_locale_get_default(TSRMLS_C);

However, in 5.5.14 branch it looks like this:

        loc_name = INTL_G(default_locale);

And this is incorrect. This was done in commit a6b7fdeb2d68c33758cca1fbb03dc0b2b1f4e107, which is merged from 5.4, but in 5.4 the default locale can not be null, while in 5.5 and above it can. So the merge was incorrect there.

However, in 5.5.15 branch it seems to be back to normal, so once 5.5.15 is release it will be fine. You can also use 5.5.15 RC1 or any recent stapshot, it should be OK too.
 [2014-07-13 06:49 UTC] stas@php.net
"5.4, 5.5" should be read as "5.5, 5.6"
 [2014-07-13 06:49 UTC] stas@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: stas
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Nov 17 22:01:34 2019 UTC