-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
gh-111178: Avoid calling functions from incompatible pointer types in descrobject.c #112861
Merged
Conversation
This file contains 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
Contributor
chrstphrchvz
commented
Dec 8, 2023
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Issue: UBSan: Calling a function through pointer to incorrect function type is undefined behavior #111178
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
chrstphrchvz
commented
Dec 8, 2023
kulikjak
pushed a commit
to kulikjak/cpython
that referenced
this pull request
Jan 22, 2024
…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
Feb 11, 2024
…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
Sep 2, 2024
…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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.