Permalink
Browse files

Don't assert on new Closure

Summary: We're about to fatal anyway.

Reviewed By: ricklavoie

Differential Revision: D8723974

fbshipit-source-id: 94def4f2ce21e4660af2426f0c61734be0037a58
  • Loading branch information...
markw65 authored and hhvm-bot committed Jul 6, 2018
1 parent 7accdd2 commit 3873385fa60d21fe075fcdfae612e97ba81ea29d
@@ -293,7 +293,7 @@ static Variant HHVM_METHOD(Closure, call,
static ObjectData* closureInstanceCtorRepoAuth(Class* cls) {
assertx(!(cls->attrs() & (AttrAbstract|AttrInterface|AttrTrait|AttrEnum)));
assertx(!cls->needInitialization());
assertx(cls->parent() == c_Closure::classof());
assertx(cls->parent() == c_Closure::classof() || cls == c_Closure::classof());
// ensure c_Closure and ClosureHdr ptrs are scanned inside other types
(void)type_scan::getIndexForMalloc<c_Closure>();
(void)type_scan::getIndexForMalloc<ClosureHdr>();
@@ -34,6 +34,10 @@ extern const StaticString s_Closure;
struct ClosureHdr : HeapObject {
explicit ClosureHdr(uint32_t size) {
initHeader_32(HeaderKind::ClosureHdr, size);
// we need to set this here, because the next thing 'new Closure'
// will do is call the constructor, which will throw, and the
// destructor will examine this field.
ctx_bits = 0;
}
uint32_t& size() { return m_aux32; }
uint32_t size() const { return m_aux32; }
@@ -0,0 +1,5 @@
<?hh // strict
// Copyright 2004-present Facebook. All Rights Reserved.
$s = "Closure";
new Closure;
@@ -0,0 +1 @@
Fatal error: Can't create a Closure directly in %s/test/slow/closure/new_closure.php on line 5

0 comments on commit 3873385

Please sign in to comment.