Closed svallee-dev closed 4 years ago
Not sure why this is happening yet, but I found out why the code freezes into an infinite loop when using a function in the asm code.
This exception is triggered: "Collection was modified; enumeration operation may not execute." at SymbolManager.cs:911
It get caught by the try in AssemblyController.cs (line 113), and as it doesn't have a specific handler, it ends up running this code instead:
else
{
Assembler.PassNeeded = true;
}
Which I assume cause the code to just get back into another pass, which trigger the same exception, etc etc.
I replaced that line of code by a simple throw; so at least my process stop when an exception is encountered (so I can print it).
I'll keep digging, just thought you might be interested to know :)
Ok looks like the IEnumerator
But as a dirty fix, I locally changed ephemerals to a List
_ephemeralCounter--;
var ephemerals = new List<string>(_symbols.Keys.Where(k => k.Contains(sc, StringComparison.Ordinal)));
foreach (var key in ephemerals)
_symbols.Remove(key);
Oh I see: it's not that weird. ephemerals is a dynamic query of the _symbols table (the result collection is not created on the spot) so as soon as you call a Remove(), the whole enumerator is invalidated!
So this is a valid bug, but thankfully it's an easy fix :)
thank you @svallee-dev, you are right we have to essentially make ephemerals
a separate container of the symbols we are removing from _symbols
, which we are mutating. Good catch!
When I try to define and use a function, like so:
The assembler freezes, and I need to kill the process manually.