Protect against segfaults calling destroyed closures

This commit updates the drop glue generated for closures to simply
ignore null pointers. The drop glue can be called in erroneous
situations such as when a closure is invoked after it's been destroyed.
In these cases we don't want to segfault and/or corrupt memory but
instead let the normal error message from the invoke glue continue to
get propagated.

Closes #1526
This commit is contained in:
Alex Crichton
2019-05-13 07:22:33 -07:00
parent 098b67d7f0
commit 542076d658
3 changed files with 59 additions and 4 deletions

View File

@@ -119,3 +119,7 @@ exports.pass_reference_first_arg_twice = (a, b, c) => {
c(a);
a.free();
};
exports.call_destroyed = f => {
assert.throws(f, /invoked recursively or destroyed/);
};