Skip to content
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
merged 49 commits into from
Jan 2, 2024

Commits on Dec 8, 2023

  1. Update descrobject.c

    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
    chrstphrchvz committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    e9c0f5f View commit details
    Browse the repository at this point in the history
  2. Update descrobject.c

    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
    chrstphrchvz committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    31f6c07 View commit details
    Browse the repository at this point in the history
  3. Update descrobject.c

    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
    chrstphrchvz committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    b950d1a View commit details
    Browse the repository at this point in the history
  4. Update descrobject.c

    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
    chrstphrchvz committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    505a00c View commit details
    Browse the repository at this point in the history
  5. Update descrobject.c

    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
    chrstphrchvz committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    2e1b409 View commit details
    Browse the repository at this point in the history
  6. Update descrobject.c

    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 committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    b82d048 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    eb6c22e View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    60c0d7a View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    1de5a1a View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    8b57573 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    d2f06e6 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    4cd2e6d View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    f32c9e0 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    83df0df View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    a4c7f17 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    be0fb74 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    356c2fe View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    ec4ca04 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    9ebb68f View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    de99189 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    9b43a8d View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    32b8dfe View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    78419d6 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    97d3ee8 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    30cd173 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    fcce565 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    776acd7 View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    f4dfb12 View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    80da821 View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    7b903ea View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    d646a9d View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    75a4980 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    e96377d View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    0002cba View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    057c059 View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    57224d0 View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    071d2bc View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    65f0a90 View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    385dbfd View commit details
    Browse the repository at this point in the history
  40. Configuration menu
    Copy the full SHA
    a0e0ae0 View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    ff534a1 View commit details
    Browse the repository at this point in the history
  42. Configuration menu
    Copy the full SHA
    ae28dc1 View commit details
    Browse the repository at this point in the history
  43. Configuration menu
    Copy the full SHA
    547cbc0 View commit details
    Browse the repository at this point in the history
  44. Configuration menu
    Copy the full SHA
    6360a46 View commit details
    Browse the repository at this point in the history
  45. Configuration menu
    Copy the full SHA
    e823bed View commit details
    Browse the repository at this point in the history
  46. Configuration menu
    Copy the full SHA
    6c15c76 View commit details
    Browse the repository at this point in the history
  47. Configuration menu
    Copy the full SHA
    238724f View commit details
    Browse the repository at this point in the history
  48. Configuration menu
    Copy the full SHA
    cb6f751 View commit details
    Browse the repository at this point in the history

Commits on Dec 9, 2023

  1. Configuration menu
    Copy the full SHA
    dd64280 View commit details
    Browse the repository at this point in the history