-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix object instantiation refcount integrity
- Loading branch information
Showing
6 changed files
with
165 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// test object reference integrity during constructor | ||
// THANKS to Miro Swisher for discovering this issue | ||
// chuck-1.5.4.3 (ge) added Thanksgiving 2024 lol | ||
|
||
// a class definition | ||
public class Foo | ||
{ | ||
// a member function that returns `this` | ||
fun Foo getFoo() { return this; } | ||
// a constructor (takes argument for good measure) | ||
fun Foo( vec3 sz ) | ||
{ | ||
// return ourself -- note this is INSIDE Foo constructor | ||
// which means it's before this instance can be assigned | ||
// to a variable (as below); yet statements likes these | ||
// have a clean-up logic that balances reference counts; | ||
// so the refcount for Foo during instantiation must | ||
// account for this interregnum; FYI this is typically | ||
// handled by temporarily boosting the refcount during | ||
// instantiation so it cannot be deleted from within | ||
// its own constructor! | ||
this.getFoo(); | ||
} | ||
} | ||
|
||
// instantiate and assignment to variable | ||
Foo foo( @(1,2,3) ); | ||
|
||
// no crash? ok | ||
<<< "success" >>>; |