Page MenuHomeFeedback Tracker

Enforce script allows access to uninitialized variables during class inheritance - segfaulting in Linux
New, NormalPublic

Description

While using class inheritance in mods, it is possible to create a child class inherited from a base class, that allows to access class variables from the base class without initializing them, especially without calling the constructor of the base class using super.

The following code would just work fine in windows, but results in segfaults of the game in linux due to sane memory handling. Under windows the behavior is actually not defined, but windows also doesn't care about its memory.

class BaseClass {
   int foo;
}
class ChildClass : BaseClass {
  void ChildClass(int bar) {
    foo = bar;
  }
}

I know that it is hard to check for all variables, but I think enforcing to use super in the constructor of an inherited class would be a good start. There are way too many modules out there that cause segfaults due to such issues.

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Linux x64
Operating System Version
Debian Bookworm
Category
General
Steps To Reproduce

See description

Event Timeline

bzed created this task.Thu, Mar 6, 6:35 PM