Page MenuHomeFeedback Tracker

Heap corruption when right hand side of bool assignment contains conditionals
New, NormalPublic

Description

When the right hand side of a bool assignment contains conditionals, this can corrupt the heap. From what I've seen, this can have the following side-effects for unrelated variables and instances:

  • ints, bools or floats changing value randomly
  • strings turning into random garbage
  • instances getting nulled/deleted or otherwise exhibiting unexpected behavior

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
Modding
Steps To Reproduce

As an example of a problematic assignment that can cause heap corruption:

bool b = condition1 && someNumber > 0;

As a workaround, using if/else seems to prevent the issue:

bool b;
if (condition1 && someNumber > 0)
    b = true;
else
    b = false;  //! Not needed in this case, just for completeness sake

The main problem is finding WHERE exactly the corruption occurs, since it is not necessarily close to where the assignment happens.

We had a case in Expansion where the issue only became visible because it corrupted a string that was used just a few lines away from the assignment (in an unrelated instance). I was unable to come up with a minimal example for the reason that finding the point of the corruption is like finding the proverbial needle in a haystack, so unfortunately I can't provide one.

Event Timeline

lava76 created this task.Jun 15 2023, 3:37 PM
NATION added a subscriber: NATION.Jul 12 2023, 9:31 PM
polpa added a subscriber: polpa.Sun, Nov 10, 9:58 AM

will there be a fix for this?

polpa added a comment.Sun, Nov 10, 9:59 AM

a lot of time has passed and there is no solution