Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack overflow when print a KOSDelegate with args of lexicon contains itself #2883

Open
longdishort opened this issue Feb 27, 2021 · 1 comment

Comments

@longdishort
Copy link

I am trying to introduce object oriented programming based on lexicon and binded KOSDelegate, and serveral game crash happened when I debug my script.
This happened in KOS 1.2.1.0 / KSP 1.9.1 but I think it will happened in the latest version (but I can't test it.)

Here is a example of script that cause the crash:

function memberFunc {
	parameter self.
}
function new {
	local self is lexicon().
	set self:memberFunc to memberFunc@:bind(self).
	return self.
}
local obj is new().
print obj.

Some log after crash:

[EXC 15:51:05.908] StackOverflowException: The requested operation caused a stack overflow.
	kOS.Safe.Serialization.SafeSerializationMgr.DumpValue (System.Object value, System.Boolean includeType) (at <1f05d5b75d1c42729d0e0281470dcabd>:0)
	kOS.Safe.Serialization.SafeSerializationMgr.Dump (kOS.Safe.Serialization.IDumper dumper, System.Boolean includeType) (at <1f05d5b75d1c42729d0e0281470dcabd>:0)
	kOS.Safe.Serialization.SafeSerializationMgr.Serialize (kOS.Safe.Serialization.IDumper serialized, kOS.Safe.Serialization.IFormatWriter formatter, System.Boolean includeType) (at <1f05d5b75d1c42729d0e0281470dcabd>:0)
	kOS.Safe.Serialization.SafeSerializationMgr.ToString (kOS.Safe.Serialization.IDumper dumper) (at <1f05d5b75d1c42729d0e0281470dcabd>:0)
	kOS.Safe.Encapsulation.Lexicon.ToString () (at <1f05d5b75d1c42729d0e0281470dcabd>:0)
	System.String.Concat (System.Object arg0, System.Object arg1, System.Object arg2) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	kOS.Safe.Encapsulation.KOSDelegate.ToString () (at <1f05d5b75d1c42729d0e0281470dcabd>:0)
	kOS.Safe.Encapsulation.UserDelegate.ToString () (at <1f05d5b75d1c42729d0e0281470dcabd>:0)
	kOS.Safe.Serialization.SafeSerializationMgr.DumpValue (System.Object value, System.Boolean includeType) (at <1f05d5b75d1c42729d0e0281470dcabd>:0)
	kOS.Safe.Serialization.SafeSerializationMgr+<>c__DisplayClass7_0.<DumpValue>b__0 (System.Object v) (at <1f05d5b75d1c42729d0e0281470dcabd>:0)
	System.Linq.Enumerable+SelectListIterator`2[TSource,TResult].ToList () (at <fbb5ed17eb6e46c680000f8910ebb50c>:0)
	System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <fbb5ed17eb6e46c680000f8910ebb50c>:0)
	kOS.Safe.Serialization.SafeSerializationMgr.DumpValue (System.Object value, System.Boolean includeType) (at <1f05d5b75d1c42729d0e0281470dcabd>:0)
	kOS.Safe.Serialization.SafeSerializationMgr.Dump (kOS.Safe.Serialization.IDumper dumper, System.Boolean includeType) (at <1f05d5b75d1c42729d0e0281470dcabd>:0)
	kOS.Safe.Serialization.SafeSerializationMgr.Serialize (kOS.Safe.Serialization.IDumper serialized, kOS.Safe.Serialization.IFormatWriter formatter, System.Boolean includeType) (at <1f05d5b75d1c42729d0e0281470dcabd>:0)
	kOS.Safe.Serialization.SafeSerializationMgr.ToString (kOS.Safe.Serialization.IDumper dumper) (at <1f05d5b75d1c42729d0e0281470dcabd>:0)
	kOS.Safe.Encapsulation.Lexicon.ToString () (at <1f05d5b75d1c42729d0e0281470dcabd>:0)
	System.String.Concat (System.Object arg0, System.Object arg1, System.Object arg2) (at <ad04dee02e7e4a85a1299c7ee81c79f6>:0)
	kOS.Safe.Encapsulation.KOSDelegate.ToString () (at <1f05d5b75d1c42729d0e0281470dcabd>:0)
... and more

It crashs not only when I print it, but also when I run the script with some bugs in the script, which really bothers me.

@nuggreat
Copy link

duplicate of issue #1598 and will likely be fixed by PR #2882

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants