Make backtrace args array a vec
commitd0b314d61858a38278951d244156e1684528ef7e
authorShaunak Kishore <kshaunak@fb.com>
Tue, 26 Jan 2021 17:46:36 +0000 (26 09:46 -0800)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 26 Jan 2021 17:51:03 +0000 (26 09:51 -0800)
tree1ef7eeca3db9fe0d8c5a28f73c9780b1b7a04e6f
parent68287ee0217b97a54f8d76e48ea1e995afc67983
Make backtrace args array a vec

Summary:
A backtrace array is a list (varray) of frames (darrays). As a result, when we access these arrays through reflection, etc., we mark them to depth 2, so that we can serialize or otherwise observe these dvarrays in the result.

However, there is actually one dvarray at depth 3 that we should have marked: the args array. This array is provided on a best-effort basis: there's no guarantee that we have it, and in fact, in our typical production configuration, we don't have it. (Being able to optimize away locals completely is important!) This array is being observed in sandbox mode.

One fix to this problem is to mark backtraces to depth 3. However, that's not quite right, because there is other data (e.g. frame metadata) at depth 3 that we don't want to mark, because it may be a Hack array. Instead, I propose that we just convert the args array to a vec right now. This change should only affect sandbox mode; code already can't rely on the array's presence, so I think it's okay to make this change before the rest of unification.

Reviewed By: ricklavoie, dneiter

Differential Revision: D26052419

fbshipit-source-id: 9732998726f71953e86e0ccdc1f29c8215bee8b6
19 files changed:
hphp/runtime/base/backtrace.cpp
hphp/test/quick/debug_backtrace.php.expectf
hphp/test/quick/debug_backtrace_continuation.php.expectf
hphp/test/quick/debug_backtrace_continuation.php.expectf-repo
hphp/test/quick/debug_backtrace_trait.php.expectf
hphp/test/quick/fail_86pinit.php.expectf
hphp/test/quick/fail_86sinit.php.expectf
hphp/test/quick/profile/Setprofile.php.expectf
hphp/test/quick/verify-param-type.php.expectf
hphp/test/slow/debug_backtrace/metadata_async_block.php.expectf
hphp/test/slow/debug_backtrace/metadata_obj.php.expectf
hphp/test/slow/dv_array/exceptions.php.expectf
hphp/test/slow/exceptions/51.php.expect
hphp/test/slow/exceptions/52.php.expect
hphp/test/slow/exceptions/chain-fault.php.expectf
hphp/test/slow/intercept/prolog.php.expectf
hphp/test/slow/reified-generics/backtrace-on-exit.php.expectf
hphp/test/zend/good/Zend/tests/debug_backtrace_limit.php.expectf
hphp/test/zend/good/Zend/tests/debug_backtrace_options.php.expectf