Open thexa4 opened 8 years ago
We are aware of this issue. There is currently no detection of cyclic references in a few places.
That's good to know, I'm currently trying to work with code like this which prevents me from printing anything at all.
local foo to lexicon("count", 0).
function bar { parameter this. set this["count"] to this["count"] + 1. }
set foo["inc"] to bar@:bind(foo).
print foo["inc"]. //This crashes
Replacing the toString function on kOS.Safe.Encapsulation.KOSDelegate.cs:146 with return "KOSDelegate";
seems to make debugging workable again but is probably not a long term solution.
Hallo! I just hit this same problem today. It'd be really really great if a fix for this could be merged, even if it's not a full-fledged fancy pretty-printer solution. I know +1s on bug report threads are un-useful, but I see the latest activity here was about half a year ago; and I know basically nothing about KSP modding internals, so best I can do ATM is make some noise :)
For context: I'm doing some minimal extra-light OOP to hold data and related methods in Lexicon
s where (obviously) the "methods" are all some f@:bind(self)
(same as #2918). This means that there are a ton of mistakes I can make in writing code that lead to kOS dumping a Lexicon
, which then immediately causes a CDT :(
I have a branch tries to fix this but it isn't well tested, it's available here: https://github.com/thexa4/KOS/releases/tag/dev-2022-01-12 It'd be great to get feedback on this (or on the standalone version)
@thexa4 ah lovely, I saw your fork / PRs but didn't realize you'd made a compiled version. I'll give it a spin... today evening? Worst case over the weekend, and report back.
@thexa4 I grabbed the kOS.dll
and kOS.Safe.dll
from your release, plopped them into the right folder in my installation, and happy to report the craft that was consistently crashing the game is now consistently not-crashing the game, and instead giving me a nice, helpful error message:
I'll keep trying to do nasty things to kOS scripts and see if I manage to break it, but at least at first glance, on the case that brought me here, your build seems like a fix.
(and btw yes, insult to injury, my mistake in the code was the dumbest typo ever)
Alrighty, so: I've now done all the over-engineering I had in mind - there's unit testing, there's pieces of a higher-level GUI library, and a cross-core / cross-vessel RPC implementation (https://github.com/abesto/kos-scripts/blob/main/lib/rpc.ks). Through all this I didn't have a single crash, and error outputs were always valid.
The following code immediately crashes KSP for me using version 0.19.3:
Lists have the same problem:
Nothing seems to be written to the KSP log when it crashes. Probably related to #1379
Due to this things like the following code crash as well, making debugging very hard as any print call can crash KSP: