Skip to content

lpython emulation mode segfaults #2123

Closed
@certik

Description

@certik

This fixes it:

--- a/src/runtime/lpython/lpython.py
+++ b/src/runtime/lpython/lpython.py
@@ -729,14 +729,9 @@ def c_p_pointer(cptr, targettype, targetshape=None):
         newa = ctypes.cast(cptr, targettype_ptr)
         return newa
     else:
-        if py_is_dataclass(targettype):
-            if cptr.value is None:
-                return None
-            return ctypes.cast(cptr, ctypes.py_object).value
-
         targettype_ptr = ctypes.POINTER(targettype_ptr)
         newa = ctypes.cast(cptr, targettype_ptr)
-        if is_ctypes_Structure(targettype):
+        if is_dataclass(targettype):
             # return after wrapping newa inside PointerToStruct
             return PointerToStruct(newa)
         return newa

I need to find a reproducer still. This is the bug:

(HOST)  C BEFORE : { 0 ,  0 ,  0 , ...,  0 ,  0 }
./run_full_emulation.sh: line 6: 31565 Segmentation fault: 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    BLOCKERworkaround not found yetbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions