You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vector.push_back may cause a memory leak / memory issue
Minimal Example to Reproduce Behavior
def keys(Map map)
{
var v = Vector();
for( i : map )
{
v.push_back(i.first());
}
return v;
}
var k = Vector();
if ( true )
{
var m = ["a":"x", "b":"y", "c":"z"];
k = keys(m);
}
print(k); // expected output should be "[a, b, c]", however sometimes it is "[, b, c]" or a crash of chaiscript
Remember to execute this example more than once! The bug may not always appear. It is like one of five executions on my system.
Not sure, whether this was reported before or is already resolved, but I thought I should just place it here...
v.push_back(clone(i.first()));
will be a workaround.
There are several preconditions: It seems to appear only with the key part of a map entry and also the map needs to be out of the scope (if-body) related tothe print command. I assume that "m" is deleted before the print command, making the key members of the vector invalid.
Well, at the end, I am not sure whether this is feature of a bug, but at least it is unexpected and may cause really wired problems.
The text was updated successfully, but these errors were encountered:
olikraus
changed the title
Memory issue with Vector.push_back()
Memory issue with Map keys and Vector.push_back()
Apr 25, 2022
Expected Behavior
Vector.push_back should work
Actual Behavior
Vector.push_back may cause a memory leak / memory issue
Minimal Example to Reproduce Behavior
Remember to execute this example more than once! The bug may not always appear. It is like one of five executions on my system.
Not sure, whether this was reported before or is already resolved, but I thought I should just place it here...
will be a workaround.
There are several preconditions: It seems to appear only with the key part of a map entry and also the map needs to be out of the scope (if-body) related tothe print command. I assume that "m" is deleted before the print command, making the key members of the vector invalid.
Well, at the end, I am not sure whether this is feature of a bug, but at least it is unexpected and may cause really wired problems.
The text was updated successfully, but these errors were encountered: