SILGen: Fix infinite destructor loop.

Putting 'this' in a box causes 'this' to be released with the box at the end of the destructor and infinite-loop. Double-retain it to work around this. Gross.

Swift SVN r4752
This commit is contained in:
Joe Groff
2013-04-16 02:45:45 +00:00
parent 519c9aec9e
commit ded5883eb4

View File

@@ -615,6 +615,9 @@ SILValue SILGenFunction::emitDestructorProlog(ClassDecl *CD,
if (DD) {
// FIXME: Bump the retain count so that destruction doesn't fire
// recursively while passing 'this' around in the destructor body.
// FIXME: We have to retain it twice to counter the release that will happen
// when the 'this' box is released below. Gross.
B.createRetain(DD, thisValue);
B.createRetain(DD, thisValue);
// Make a box for 'this' in the body's scope.