codon icon indicating copy to clipboard operation
codon copied to clipboard

Segmentation fault is caused with pyext mode when a method takes an object of another class as input

Open yoshipon opened this issue 1 year ago • 1 comments

Hi, thank you for maintaining this fantastic software.

I found that the following codon code compiled with -pyext:

@dataclass(python=True, repr=True)
class Foo:
    a: float


@dataclass(python=True, repr=True)
class Bar:
    def func(self, foo: Foo):
        print(foo)


def func(foo: Foo):
    print(foo)

can cause segmentation fault by the following Python code

from codon_module import Foo, Bar

Bar().func(Foo())

I also found the following code properly works:

from codon_module import Foo, func

func(Foo())

yoshipon avatar Aug 04 '23 13:08 yoshipon

I now also got the following new finding. In my environment, the following codon code with the Python code Bar().func(Foo()) outputs 0 (, which might be NULL...?)

@dataclass(python=True, repr=True)
class Bar:
    def func(self, foo: Foo):
        print(id(foo))

yoshipon avatar Aug 04 '23 13:08 yoshipon