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

Strange behavior associated with a segmentation fault #487

Closed
iSunfield opened this issue Oct 10, 2023 · 1 comment
Closed

Strange behavior associated with a segmentation fault #487

iSunfield opened this issue Oct 10, 2023 · 1 comment
Assignees

Comments

@iSunfield
Copy link

iSunfield commented Oct 10, 2023

I am struggling with strange behavior related to a segmentation fault while trying to implement a derived class to hold data in an Array. Could I get some advice? I've extracted the minimal code that reproduces the error, and below I present code snippets that cause the segmentation fault and those that do not.

The following code results in a segmentation fault

class Base:
    InBuffer : Array[UInt[64]]
    OutBufferA : Array[UInt[64]]
    OutBufferB : Array[UInt[64]]

    def __init__(self,BufferSize:int):
        self.OutBufferA = Array[UInt[64]](BufferSize)
        self.OutBufferB = Array[UInt[64]](BufferSize)
        self.InBuffer = Array[UInt[64]](10)
    
    def Exe(self,Id:int):
        pass

class TestMod(Base):
    def __init__(self,BufferSize:int):
        super().__init__(BufferSize)
        
    def Exe(self,Id:int):
        print(Id)       


if __name__ == "__main__":
    In : Array[UInt[64]]
    line : str

    In = Array[UInt[64]](2 ** 17)
    TestM : TestMod

    TestM = TestMod(2 ** 17)
    TestM.InBuffer = In

    TestM.Exe(1)

    with open("TestDt.txt","r") as fin:
        for line in fin:
           pass

    TestM.Exe(2)

result:
  run: line 19: 1594182 Segmentation fault 

Commenting out

#TestM.InBuffer = In

or

Commenting out read file code

#with open("TestDt.txt","r") as fin:
#     for line in fin:
#       pass

resolves the segmentation fault.

result:
1
2
 *  Terminal will be reused by tasks, press any key to close it. 

"TestDt.txt" is below.

8,
+0.000000000 ,+0.000000000 ,+0.000000000 ,+0.000000000 ,+0.000000000 ,+0.000000000 ,+0.000000000 ,+0.000000000 ,

@arshajii
Copy link
Contributor

Thanks for the report, @iSunfield -- this looks like an issue with inheritance. We'll take a look and follow up ASAP. If you use static inheritance via class TestMod(Static[Base]) it seems to work.

inumanag added a commit that referenced this issue Jan 12, 2024
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

3 participants