Skip to content

Fix incorrect function signatures in _testmultiphase (UBSan) #141553

@ashm-dev

Description

@ashm-dev

Bug report

Bug description:

UBSan reports errors such as:

modexport_create_string

Objects/moduleobject.c:546:13: runtime error: call to function modexport_create_string through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct PyModuleDef *)' /home/shamil/oss/cpython/main/./Modules/_testmultiphase.c:1066:5: note: modexport_create_string defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/moduleobject.c:546:13

Py_mod_state_free

Objects/moduleobject.c:1101:9: runtime error: call to function modexport_smoke_free through pointer to incorrect function type 'void (*)(void *)' /home/shamil/oss/cpython/main/./Modules/_testmultiphase.c:974: note: modexport_smoke_free defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/moduleobject.c:1101:9

The functions assigned to Py_mod_state_free and modexport_create_string use incorrect signatures, causing calls through mismatched function pointer types and leading to undefined behavior.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.15new features, bugs and security fixesextension-modulesC modules in the Modules dirtestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions