Bug #79311 [PATCH]: enchant_dict_suggest() function fails on Big endian architecture

From: Date: Fri, 28 Feb 2020 04:24:25 +0000
Subject: Bug #79311 [PATCH]: enchant_dict_suggest() function fails on Big endian architecture
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225767@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 Patch added by: vibhutisawant18@gmail.com Reported by: vibhutisawant18 at gmail dot com Summary: enchant_dict_suggest() function fails on Big endian architecture Status: Verified Type: Bug Package: Enchant related Operating System: Ubuntu 16.04 PHP Version: master-Git-2020-02-27 (Git) Block user comment: N Private report: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [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 (#225767) next »