Fix crashes related to "new Pair($x, $y)"
commit247e307f03d1d2d3958da8e5b98953827df68d73
authorDrew Paroski <andrewparoski@fb.com>
Tue, 15 Jul 2014 02:24:10 +0000 (14 19:24 -0700)
committerfacebook-github-bot <githubbot@fb.com>
Tue, 15 Jul 2014 02:30:22 +0000 (14 19:30 -0700)
treee625b7d79b8598c68cfce7f22cde5e94b28b46a4
parent74d6a92169daa541948f3f3163fc31881c43dc6d
Fix crashes related to "new Pair($x, $y)"

Summary: "new Pair" is supposed to throw an exception with any number of arguments,
However, there was a crash when running under hphpd that could happen if
one or more arguments were passed. The problem was that HHVM was raising a
warning and then returning a partially constructed Pair with uninitialized
fields.

This diff fixes the crash by making "new" use a more defensive C++
constructor that initializes all the field, and by making Pair's
__construct() method take any number of args (which ensures that "new Pair"
will always throw an exception no matter how many args are passed).

Reviewed By: @jdelong

Differential Revision: D1432922
hphp/runtime/ext/ext_collections.cpp
hphp/runtime/ext/ext_collections.h
hphp/runtime/vm/runtime.cpp
hphp/runtime/vm/runtime.h
hphp/system/idl/collections.idl.json
hphp/test/slow/collection_classes/pair-new.php [new file with mode: 0644]
hphp/test/slow/collection_classes/pair-new.php.expect [new file with mode: 0644]