gh-111178: Avoid calling functions from incompatible pointer types in descrobject.c by chrstphrchvz · Pull Request #112861 · python/cpython
added 30 commits
Objects/descrobject.c:1913:5: warning: cast from 'void (*)(mappingproxyobject *)' to 'destructor' (aka 'void (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict]
1913 | (destructor)mappingproxy_dealloc, /* tp_dealloc */
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Example UBSan error:
Python/generated_cases.c.h:3315:13: runtime error: call to function mappingproxy_dealloc through pointer to incorrect function type 'void (*)(struct _object *)'
descrobject.c:1160: note: mappingproxy_dealloc defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/generated_cases.c.h:3315:13 in
Objects/descrobject.c:808:5: warning: cast from 'PyObject *(*)(PyMemberDescrObject *, PyObject *, PyObject *)' (aka 'struct _object *(*)(PyMemberDescrObject *, struct _object *, struct _object *)') to 'descrgetfunc' (aka 'struct _object *(*)(struct _object *, struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict]
808 | (descrgetfunc)member_get, /* tp_descr_get */
| ^~~~~~~~~~~~~~~~~~~~~~~~
Objects/descrobject.c:809:5: warning: cast from 'int (*)(PyMemberDescrObject *, PyObject *, PyObject *)' (aka 'int (*)(PyMemberDescrObject *, struct _object *, struct _object *)') to 'descrsetfunc' (aka 'int (*)(struct _object *, struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict]
809 | (descrsetfunc)member_set, /* tp_descr_set */
| ^~~~~~~~~~~~~~~~~~~~~~~~
Example UBSan error:
Objects/object.c:1682:19: runtime error: call to function member_set through pointer to incorrect function type 'int (*)(struct _object *, struct _object *, struct _object *)'
descrobject.c:227: note: member_set defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:1682:19 in
Objects/object.c:1564:19: runtime error: call to function member_get through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct _object *, struct _object *)'
descrobject.c:160: note: member_get defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:1564:19 in
Example compiler warning:
Objects/descrobject.c:703:5: warning: cast from 'void (*)(PyDescrObject *)' to 'destructor' (aka 'void (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict]
703 | (destructor)descr_dealloc, /* tp_dealloc */
| ^~~~~~~~~~~~~~~~~~~~~~~~~
Example UBSan error:
Objects/object.c:2857:5: runtime error: call to function descr_dealloc through pointer to incorrect function type 'void (*)(struct _object *)'
descrobject.c:23: note: descr_dealloc defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:2857:5 in
Objects/descrobject.c:771:5: warning: cast from 'PyObject *(*)(PyMethodDescrObject *, PyObject *, PyObject *)' (aka 'struct _object *(*)(PyMethodDescrObject *, struct _object *, struct _object *)') to 'descrgetfunc' (aka 'struct _object *(*)(struct _object *, struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict]
771 | (descrgetfunc)classmethod_get, /* tp_descr_get */
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Example UBSan error:
Objects/typeobject.c:10293:24: runtime error: call to function classmethod_get through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct _object *, struct _object *)'
descrobject.c:94: note: classmethod_get defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/typeobject.c:10293:24 in
Objects/descrobject.c:845:5: warning: cast from 'PyObject *(*)(PyGetSetDescrObject *, PyObject *, PyObject *)' (aka 'struct _object *(*)(PyGetSetDescrObject *, struct _object *, struct _object *)') to 'descrgetfunc' (aka 'struct _object *(*)(struct _object *, struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict]
845 | (descrgetfunc)getset_get, /* tp_descr_get */
| ^~~~~~~~~~~~~~~~~~~~~~~~
Objects/descrobject.c:846:5: warning: cast from 'int (*)(PyGetSetDescrObject *, PyObject *, PyObject *)' (aka 'int (*)(PyGetSetDescrObject *, struct _object *, struct _object *)') to 'descrsetfunc' (aka 'int (*)(struct _object *, struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict]
846 | (descrsetfunc)getset_set, /* tp_descr_set */
| ^~~~~~~~~~~~~~~~~~~~~~~~
Example UBSan error:
Objects/typeobject.c:4861:19: runtime error: call to function getset_get through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct _object *, struct _object *)'
descrobject.c:180: note: getset_get defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/typeobject.c:4861:19 in
Objects/descrobject.c:739:5: warning: cast from 'PyObject *(*)(PyMethodDescrObject *, PyObject *, PyObject *)' (aka 'struct _object *(*)(PyMethodDescrObject *, struct _object *, struct _object *)') to 'descrgetfunc' (aka 'struct _object *(*)(struct _object *, struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict]
739 | (descrgetfunc)method_get, /* tp_descr_get */
| ^~~~~~~~~~~~~~~~~~~~~~~~
Example UBSan error:
Objects/object.c:1621:15: runtime error: call to function method_get through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct _object *, struct _object *)'
descrobject.c:138: note: method_get defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:1621:15 in
kulikjak pushed a commit to kulikjak/cpython that referenced this pull request
…pes in descrobject.c (pythonGH-112861) Fix undefined behavior warnings (UBSan -fsanitize=function), for example: Python/generated_cases.c.h:3315:13: runtime error: call to function mappingproxy_dealloc through pointer to incorrect function type 'void (*)(struct _object *)' descrobject.c:1160: note: mappingproxy_dealloc defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/generated_cases.c.h:3315:13 in
aisk pushed a commit to aisk/cpython that referenced this pull request
…pes in descrobject.c (pythonGH-112861) Fix undefined behavior warnings (UBSan -fsanitize=function), for example: Python/generated_cases.c.h:3315:13: runtime error: call to function mappingproxy_dealloc through pointer to incorrect function type 'void (*)(struct _object *)' descrobject.c:1160: note: mappingproxy_dealloc defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/generated_cases.c.h:3315:13 in
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request
…pes in descrobject.c (pythonGH-112861) Fix undefined behavior warnings (UBSan -fsanitize=function), for example: Python/generated_cases.c.h:3315:13: runtime error: call to function mappingproxy_dealloc through pointer to incorrect function type 'void (*)(struct _object *)' descrobject.c:1160: note: mappingproxy_dealloc defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/generated_cases.c.h:3315:13 in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters