kekyo / IL2C

IL2C - A translator for ECMA-335 CIL/MSIL to C language.
Apache License 2.0
401 stars 36 forks source link

The parsing can get into endless loop, and abort with StackOverflowException #105

Closed cyborgyn closed 2 years ago

cyborgyn commented 2 years ago

If we try to transpile a struct, where one of the static fields are themselves, the transpilation fails with StackOverflowException. Example:

    public struct MyStruct
    {
        private int value;

        public static MyStruct Default = new MyStruct(1000);

        public MyStruct(int value) { this.value = value; }
    }
kekyo commented 2 years ago

@cyborgyn The static field initializer (translated type initializer) implicitly depends correct initializing sequence graph. I don't check a requirements on ECMA-335 and don't have much insight now...

97 and #98 related, first related issue is #4

If we don't any resolve correcting, may cause the binary touch uninitialized data...?

kekyo commented 2 years ago

Bit related? #85

kekyo commented 2 years ago

@cyborgyn Sorry for the very delay. I understood #100 work and imported it with cherry-pick. https://github.com/kekyo/IL2C/commit/2cbb6f1da780acb289fb9f98d7b4adda99fd06c3