AS rev 684 (release 2.19.2)
class Big{ Big() { Log("Big instance created"); } ~Big() { Log("Big instance being destroyed"); } void exec() { Log("executed"); }}Big big;class SomeClass{ Big@ local_big; SomeClass() { @local_big = @big; local_big.exec(); } ~SomeClass() { Log("SomeClass instance being destroyed"); big.exec(); }}SomeClass@[] some;void test_main(){ some.resize(1); SomeClass something; @some[0]=something;}
When I load the module, I see:
Big instance created
And that's fine, I have one global instance of Big in there.
Then I execute test_main(), the log displays
executed
which again is fine and asserts that local_big handle actually points somewhere.
Then I unload all scripts and the log says
Big instance createdBig instance being destroyedSomeClass instance being destroyed
then it crashes, trying to execute big.exec().
So, I see the constructor for Big called twice. I could understand that if @local_big = @big would actually create a copy of big (this would also explain why original big were garbaged before my SomeClass instance, thus leading to crash in it's destructor - since the instance weren't holding a reference to it, but to it's copy). But I see the second constructor call occuring right after I unload the scripts, when everything gets to be garbaged. This ain't no log buffer flushing problem on my part, I am quite sure. And I suspect @local_big = @big shouldn't actually copy anything?