by Apeirogon » Sat Sep 03, 2022 9:35 am
Well, exception from destructor if there are already some exception happened, lead to instant termination of a program, but that not the point and not entirely what I meant.
Just to be clear, this
Code: Select all
version "3.8"
const MAX_SIZE = 6;
class thing : thinker
{
pointer others[MAX_SIZE];
static thing constructor()
{
let t = new("thing");
t.others[0] = new("pointer");
t.others[1] = new("pointer");
t.others[2] = new("pointer");
t.others[3] = new("pointer");
t.others[4] = new("pointer");
t.others[5] = new("pointer");
return t;
}
override void ondestroy()
{
for(int i = 0; i < MAX_SIZE; i++)
{
if(others[i])
{
console.printf("OH NO");
others[i].p.others[i] = null;
}
}
super.ondestroy();
}
void out_of_bound_write(int a, thing t)
{
others[a].p = t;
}
}
class pointer
{
thing p;
}
class debug_build : eventhandler
{
override void NetworkProcess (ConsoleEvent e)
{
if(e.name == "bug")
{
array<thing> t; t.clear();
t.push(thing.constructor() );
t.push(thing.constructor() );
t[0].out_of_bound_write(MAX_SIZE, t[1]);
}
}
}
will crash and flood console with "oops, cant destroy thinker" messages...which is expected. Stack unwinding, exception bytes and other scary words.
HOWEVER, if you relaunch game from main menu or switch map with CCMD, without relaunching Gzdoom, it would work fine.
Archive in first post after crashing VM also crashes Gzdoom if you try launching a new game, which should not happens.
Well, exception from destructor if there are already some exception happened, lead to instant termination of a program, but that not the point and not entirely what I meant.
Just to be clear, this
[code]version "3.8"
const MAX_SIZE = 6;
class thing : thinker
{
pointer others[MAX_SIZE];
static thing constructor()
{
let t = new("thing");
t.others[0] = new("pointer");
t.others[1] = new("pointer");
t.others[2] = new("pointer");
t.others[3] = new("pointer");
t.others[4] = new("pointer");
t.others[5] = new("pointer");
return t;
}
override void ondestroy()
{
for(int i = 0; i < MAX_SIZE; i++)
{
if(others[i])
{
console.printf("OH NO");
others[i].p.others[i] = null;
}
}
super.ondestroy();
}
void out_of_bound_write(int a, thing t)
{
others[a].p = t;
}
}
class pointer
{
thing p;
}
class debug_build : eventhandler
{
override void NetworkProcess (ConsoleEvent e)
{
if(e.name == "bug")
{
array<thing> t; t.clear();
t.push(thing.constructor() );
t.push(thing.constructor() );
t[0].out_of_bound_write(MAX_SIZE, t[1]);
}
}
}[/code]
will crash and flood console with "oops, cant destroy thinker" messages...which is expected. Stack unwinding, exception bytes and other scary words.
HOWEVER, if you relaunch game from main menu or switch map with CCMD, without relaunching Gzdoom, it would work fine.
Archive in first post after crashing VM also crashes Gzdoom if you try launching a new game, which should not happens.