[since 3607ffa] 'ictionary' is freed outside the GC process.

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
User avatar
m8f
 
 
Posts: 1445
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Manjaro Linux
Location: Siberia (UTC+7)
Contact:

[since 3607ffa] 'ictionary' is freed outside the GC process.

Post by m8f »

Steps to reproduce:
1. Start any game (e.g. Doom 2) with ictionary.pk3 loaded.
ictionary.pk3
(544 Bytes) Downloaded 16 times
2. Save the game.
3. Load the saved game.
4. Open console. Console says:

Code: Select all

Warning: 'ictionary' is freed outside the GC process.
This warning is introduced with commit 3607ffa, which is my fix for Dictionary memory leak.

Code to cause the error (the same as in the attached pk3):

Code: Select all

class ictionaryEventHandler : EventHandler
{
  override void WorldLoaded(WorldEvent e)
  {
    dict = Dictionary.Create();
  }

  Dictionary dict;
}
Is it severe? How do I fix it?

Edit: OnRegister was changed to WorldLoaded. The warning is the same.
Last edited by m8f on Sun May 17, 2020 12:32 pm, edited 1 time in total.
User avatar
Major Cooke
Posts: 8176
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: [since 3607ffa] 'ictionary' is freed outside the GC proc

Post by Major Cooke »

You're not supposed to use OnRegister for that unfortunately. Graf made a commit long ago that stated it should only ever be used for setting the order. If I recall correctly, isn't it called whenever a game is loaded?

See this commit.

The only way I can see this problem getting solved is if there's a WorldPreLoaded function being called before anything else since WorldLoaded appears to be called after everything's spawned in.
User avatar
m8f
 
 
Posts: 1445
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Manjaro Linux
Location: Siberia (UTC+7)
Contact:

Re: [since 3607ffa] 'ictionary' is freed outside the GC proc

Post by m8f »

That's a surprise. Thanks for the info!

So, the only function that can be called in OnRegister is SetOrder?

Should I update the wiki, then? Right now it says "Initialization can be performed here." in OnRegister description.

Unfortunately, after changing OnRegister to WorldLoaded the warning stays there. The test pk3 is updated in the OP.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49073
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [since 3607ffa] 'ictionary' is freed outside the GC proc

Post by Graf Zahl »

The original event handler system had a few serious design flaws, and worse, some mods depend on these design flaws or at least a resonable emulation of the bad behavior.

The message you get comes from explicitly deleting a GC'd object - you shouldn't do that but call Destroy() instead.
User avatar
m8f
 
 
Posts: 1445
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Manjaro Linux
Location: Siberia (UTC+7)
Contact:

Re: [since 3607ffa] 'ictionary' is freed outside the GC proc

Post by m8f »

Post Reply

Return to “Closed Bugs [GZDoom]”