Skip to content

Commit

Permalink
Suppress HAC ref-bind notices when setting up fb_intercept
Browse files Browse the repository at this point in the history
Summary: It's doing an `appendRef` but the array isn't leaking anywhere, it's just being used in `invokeFunc`. The argument array (which gets created with `appendWithRef` does leak to the function doing an intercept but only contains refs when intercepting a function that's already pass-by-ref.

Reviewed By: ricklavoie

Differential Revision: D14961879

fbshipit-source-id: e236bdf60d55859bc528a95e15d591351cc8581d
  • Loading branch information
paulbiss authored and hhvm-bot committed Apr 19, 2019
1 parent 293029e commit d1af316
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hphp/runtime/vm/event-hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ static Array get_frame_args_with_ref(const ActRec* ar) {
int numNonVariadic = ar->func()->numNonVariadicParams();
int numArgs = ar->numArgs();

SuppressHACRefBindNotices _guard;
PackedArrayInit retArray(numArgs);

auto local = reinterpret_cast<TypedValue*>(
Expand Down Expand Up @@ -301,6 +302,7 @@ static Variant call_intercept_handler(
}
intArgs = par.append(done).toArray();
} else {
SuppressHACRefBindNotices _guard;
Variant tmp;
tmp.assignRef(done);
intArgs = par.appendWithRef(tmp).toArray();
Expand Down
12 changes: 12 additions & 0 deletions hphp/test/slow/intercept/hac-warnings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?hh

<<__NEVER_INLINE>>
function foo() {}

function intercept($n) { var_dump($n); }

<<__EntryPoint>>
function main() {
fb_intercept('foo', 'intercept');
foo();
}
1 change: 1 addition & 0 deletions hphp/test/slow/intercept/hac-warnings.php.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
string(3) "foo"
1 change: 1 addition & 0 deletions hphp/test/slow/intercept/hac-warnings.php.hphp_opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-vJitEnableRenameFunction=1 -vHackArrCompatNotices=1
1 change: 1 addition & 0 deletions hphp/test/slow/intercept/hac-warnings.php.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-vEval.HackArrCompatNotices=1 -vEval.HackArrCompatCheckRefBind=1

0 comments on commit d1af316

Please sign in to comment.