|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2022-06-02 03:55 UTC] maghsodid at yahoo dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 14:00:01 2025 UTC |
Description: ------------ Apparently Lua->assign() really hates floats. I've found this come in several varieties. If you have an array containing anything, then a key with a float value, then an array with a numeric key (I encountered this trying to pass along the $_SERVER variable - this is the smallest case I could get it down to), you will get a segmentation fault (Case C in test). I then tried to narrow this down to just passing the float - which works fine. However, passing an array with just the float complains about an unknown type error (Case B in test), and passing a specially crafted array with one key before the float seems to skip the float's key (Case A in test). Examples below - they probably explain it better than I do. Test script: --------------- <?php // /usr/local/debug.lua is function run() return input end register_shutdown_function('LuaC'); // So that we can 'catch' the fatal error from LuaB and run LuaC $LuaA=new Lua("/usr/local/debug.lua"); // Case A: the variable then float echo "LuaA:\n"; $LuaA->assign("input",['a'=>'b','float'=>1.1]); var_dump($LuaA->run()); $LuaB=new Lua("/usr/local/debug.lua"); // Case B: the float alone echo "LuaB:\n"; $LuaB->assign("input",['float'=>1.1]); var_dump($LuaB->run()); function LuaC() // So that we can 'catch' the fatal error from LuaB and run LuaC { $LuaC=new Lua("/usr/local/debug.lua"); // Case C: the segfault echo "LuaC:\n"; $LuaC->assign("input",['a'=>'b','float'=>1.1,'c'=>['e']]); var_dump($LuaC->run()); } Expected result: ---------------- LuaA: array(2) { ["a"]=> string(1) "b" ["float"]=> float(1.1) } LuaB: array(1) { ["float"]=> float(1.1) } LuaC: array(3) { ["a"]=> string(1) "b" ["float"]=> float(1.1) ["c"]=> array(1) { [0]=> string(1) "e" } } Actual result: -------------- LuaA: array(1) { ["a"]=> float(1.1) } LuaB: Fatal error: Lua::assign(): unsupported type `unknown' for lua in <file> on line 10 LuaC: Segmentation fault: 11