Skip to content

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

@longdishort

Description

@longdishort

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions