Bug #70542 [Opn]: dcngettext test crash due to invalid "category" parameter

From: Date: Tue, 22 Sep 2015 04:05:09 +0000
Subject: Bug #70542 [Opn]: dcngettext test crash due to invalid "category" parameter
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196148@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70542&edit=1 ID: 70542 Updated by: laruence@php.net Reported by: rainer dot jung at kippdata dot de Summary: dcngettext test crash due to invalid "category" parameter Status: Open Type: Bug Package: Gettext related Operating System: Solaris PHP Version: 7.0.0RC3 Block user comment: N Private report: N New Comment: I can not reproduce this on Linux Previous Comments: ------------------------------------------------------------------------ [2015-09-21 08:47:15] rainer dot jung at kippdata dot de Description: ------------ ext/gettext/tests/dcngettext.php crashes (segmentation fault) on Solaris due to the invalid catagory parameter with value "-1". Linux has special provisions in the source code for invalid category values, but on Solaris invalid values make the test crash. The original crash stack is: fee94ecc get_hashid (fdc5f328, fdc5f328, fdc5f328, ffffffff, ffffffff, 1) fee92fd4 dcngettext (fdc5f328, fdc5f328, fdc5f328, ffffffff, ffffffff, ffbfec08) + 94 fef41a28 zif_dcngettext (fdc13170, fdc130d0, 5f, 8dfb0, 44138, 2) + 9c fe7d0370 ZEND_DO_ICALL_SPEC_HANDLER (fdc13020, fdc80508, feda83d8, fdc13170, fdc13020, fdc80508) + 50 fe7bccd0 execute_ex (fdc13020, 0, ffffffff, fffffff8, 0, feda83d8) + 24 fe822838 zend_execute (fdc6c1e0, 0, 0, 0, fdc13020, feda83d8) + 1c0 fe77c450 zend_execute_scripts (8, 0, 3, 1, feda83d8, ffbff500) + a8 fe7154f0 php_execute_script (ffbff500, 6, 0, 1, 0, feda8828) + 27c 00014110 do_cli (1, fffe6820, 1cf10, 13dc00, 3b7d8, 14) + 1098 0001cac8 main (0, 0, 5d, 1d258, 3741c, 1cc50) + 3e8 000128f4 _start (0, 0, 0, 0, 0, 0) + 5c and the crash can easily reproduced by simply calling dcgettext("test", "test", -1) on Solaris (or dcngettext("test", "test", "test", -1, -1) if you like). You might want to either use category value 0 which seems to exist for all platforms, but might change test output, or LC_ALL which IMHO returns the same result on Linux and is always valid. Unfortunately LC_ALL is not available in the gettext ext as a constant, so it might make sense (not only to fix this bug) to add the usual constants to the gettext extension. Looking at the standards documentation of locale.h that would be: LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME The corresponding integer values would need to be determined form local.h during PHP compile time. The invalid value -1 is also used as a category in some parts of the test ext/gettext/tests/44938.phpt: var_dump(dcgettext($overflown, $msgid, -1)); var_dump(dcgettext($domain, $overflown, -1)); var_dump(dcngettext($overflown, $msgid, $msgid, -1, -1)); var_dump(dcngettext($domain, $overflown, $msgid, -1, -1)); var_dump(dcngettext($domain, $msgid, $overflown, -1, -1)); For this test there's no crash, I think because it first detects the overly long argument it tests for, so the atual gettext library call is never done. Note also, that only the category argument -1 is invalid, not e.g. the -1 in var_dump(ngettext($overflown, $msgid, -1)); or the first of the two -1 in var_dump(dcngettext($domain, $msgid, $overflown, -1, -1)); Note that IMHO this is not a duplicate of https://bugs.php.net/bug.php?id=47663 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70542&edit=1

« previous php.bugs (#196148) next »