Skip to content

Wrapping a Pointer where auto_dealloc is True with another Pointer will cause double free. #492

Description

@CookStar

Code:

from memory import Pointer
from memory import alloc

def test_pointer():
    ptr = alloc(4)
    Pointer(ptr)

test_pointer()

Output:

free(): double free detected in tcache 2

This also applies to CustomType.

Code:

from memory import alloc
from memory import make_object
from memory.manager import CustomType
from memory.manager import TypeManager

manager = TypeManager()

class Test(CustomType, metaclass=manager):
    _size = 4

def test_customtype():
    ptr = alloc(4)
    make_object(Test, ptr)

test_customtype()

Output:

free(): double free detected in tcache 2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions