Bug #79311 [Ver->Csd]: enchant_dict_suggest() fails on big endian architecture

From: Date: Fri, 28 Feb 2020 14:47:04 +0000
Subject: Bug #79311 [Ver->Csd]: enchant_dict_suggest() fails on big endian architecture
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225787@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79311&edit=1 ID: 79311 Updated by: cmb@php.net Reported by: vibhutisawant18 at gmail dot com Summary: enchant_dict_suggest() fails on big endian architecture -Status: Verified +Status: Closed Type: Bug Package: Enchant related Operating System: Ubuntu 16.04 PHP Version: PHP 7.3 Assigned To: cmb Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmbecker69@gmx.de Revision: http://git.php.net/?p=php-src.git;a=commit;h=6adb885966502f53c69b9aeb0e2cbbeac3d6c65a Log: Fix #79311: enchant_dict_suggest() fails on big endian architecture Previous Comments: ------------------------------------------------------------------------ [2020-02-28 12:32:28] cmb@php.net Thanks for the patch! I would prefer to clean that up right away; could you please check PR #5222 (see link above)? ------------------------------------------------------------------------ [2020-02-28 12:31:31] cmb@php.net The following pull request has been associated: Patch Name: Fix #79311: enchant_dict_suggest() fails on big endian architecture On GitHub: https://github.com/php/php-src/pull/5222 Patch: https://github.com/php/php-src/pull/5222.patch ------------------------------------------------------------------------ [2020-02-28 04:24:25] vibhutisawant18 at gmail dot com The following patch has been added/updated: Patch Name: dict_suggest_patch.patch Revision: 1582863865 URL: https://bugs.php.net/patch-display.php?bug=79311&patch=dict_suggest_patch.patch&revision=1582863865 ------------------------------------------------------------------------ [2020-02-27 11:06:32] cmb@php.net Using memcpy() to assign a size_t value to an int variable is … interesting. I'd *start* by changing this to proper assignments. ------------------------------------------------------------------------ [2020-02-27 10:50:17] vibhutisawant18 at gmail dot com Description: ------------ ext/enchant/tests/dict_suggest.phpt TC fails as enchant_dict_suggest function is not compatible on Big Endian architecture. The failure is observed at memcpy function in ext/enchant/enchant.c. enchant_dict_suggest function fails to return an array of suggestions, instead it returns null object. It can be observed that the n_sugg variable is of type int(4 bytes) whereas the n_sugg_st variable is of type size_t(8 bytes). Hence due to different memory alignment on big endian system, the memcpy fails to copy the memory blocks containing actual data. AS a workaround, I found that by declaring data type of n_sugg as size_t instead of int, the TC passed on both, Little and Big endian system.Kindly let me know if I shall raise a PR with this changes. PFB test result observed on Little and big endian architecture for respective TC(ext/enchant/tests/dict_suggest.phpt). Little endian: test@5dfe04cf73b3:~/php/php-src$ ./sapi/cli/php -f "ext/enchant/tests/dict_suggest.phpt" --TEST-- enchant_dict_suggest() function --CREDITS-- marcosptf - <marcosptf@yahoo.com.br> --SKIPIF-- --FILE-- OK OK OK --EXPECT-- OK OK OK Big endian: test@3e72af658118:~/php/php-src$ ./sapi/cli/php -f "ext/enchant/tests/dict_suggest.phpt" --TEST-- enchant_dict_suggest() function --CREDITS-- marcosptf - <marcosptf@yahoo.com.br> --SKIPIF-- --FILE-- OK OK dict suggest failed --EXPECT-- OK OK OK ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79311&edit=1

« previous php.bugs (#225787) next »