php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71810 Bizarre behavior with floats
Submitted: 2016-03-13 01:23 UTC Modified: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:-1 (-100.0%)
From: iggyvolz at gmail dot com Assigned:
Status: Open Package: lua (PECL)
PHP Version: 7.0.4 OS: Mac OS X 10.9.5
Private report: No CVE-ID: None
 [2016-03-13 01:23 UTC] iggyvolz at gmail dot com
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

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2022-06-02 03:55 UTC] maghsodid at yahoo dot com
The following pull request has been associated:

Patch Name: Fix issue with pt_BR not being updated
On GitHub:  https://github.com/php/systems/pull/15
Patch:      https://github.com/php/systems/pull/15.patch
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 13 19:01:27 2024 UTC