Title: gh-111178: Define `visitproc` callback functions properly and remove unnecessary casts in gcmodule.c by chrstphrchvz · Pull Request #112687 · python/cpython · GitHub
Open Graph Title: gh-111178: Define `visitproc` callback functions properly and remove unnecessary casts in gcmodule.c by chrstphrchvz · Pull Request #112687 · python/cpython
X Title: gh-111178: Define `visitproc` callback functions properly and remove unnecessary casts in gcmodule.c by chrstphrchvz · Pull Request #112687 · python/cpython
Description: Because many other changes are likely needed for gh-111178, I have opened this PR separately for review by the respective codeowner. The error for visit_reachable() might be the most common one I encounter. Potential compiler warnings addressed: Modules/gcmodule.c:606:21: warning: cast from 'int (*)(PyObject *, PyGC_Head *)' (aka 'int (*)(struct _object *, PyGC_Head *)') to 'visitproc' (aka 'int (*)(struct _object *, void *)') converts to incompatible function type [-Wcast-function-type-strict] 606 | (visitproc)visit_reachable, | ^~~~~~~~~~~~~~~~~~~~~~~~~~ Modules/gcmodule.c:754:25: warning: cast from 'int (*)(PyObject *, PyGC_Head *)' (aka 'int (*)(struct _object *, PyGC_Head *)') to 'visitproc' (aka 'int (*)(struct _object *, void *)') converts to incompatible function type [-Wcast-function-type-strict] 754 | (visitproc)visit_move, | ^~~~~~~~~~~~~~~~~~~~~ Modules/gcmodule.c:1707:27: warning: cast from 'int (*)(PyObject *, PyObject *)' (aka 'int (*)(struct _object *, struct _object *)') to 'visitproc' (aka 'int (*)(struct _object *, void *)') converts to incompatible function type [-Wcast-function-type-strict] 1707 | if (traverse(obj, (visitproc)referrersvisit, objs)) { | ^~~~~~~~~~~~~~~~~~~~~~~~~ Modules/gcmodule.c:1773:27: warning: cast from 'int (*)(PyObject *, PyObject *)' (aka 'int (*)(struct _object *, struct _object *)') to 'visitproc' (aka 'int (*)(struct _object *, void *)') converts to incompatible function type [-Wcast-function-type-strict] 1773 | if (traverse(obj, (visitproc)referentsvisit, result)) { | ^~~~~~~~~~~~~~~~~~~~~~~~~ A few example UBSan -fsanitize=function errors addresses: Objects/dictobject.c:3650:17: runtime error: call to function visit_reachable through pointer to incorrect function type 'int (*)(struct _object *, void *)' gcmodule.c:502: note: visit_reachable defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/dictobject.c:3650:17 in Objects/descrobject.c:694:5: runtime error: call to function visit_reachable through pointer to incorrect function type 'int (*)(struct _object *, void *)' gcmodule.c:502: note: visit_reachable defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/descrobject.c:694:5 in Objects/dictobject.c:3658:17: runtime error: call to function visit_reachable through pointer to incorrect function type 'int (*)(struct _object *, void *)' gcmodule.c:502: note: visit_reachable defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/dictobject.c:3658:17 in Objects/dictobject.c:3659:17: runtime error: call to function visit_reachable through pointer to incorrect function type 'int (*)(struct _object *, void *)' gcmodule.c:502: note: visit_reachable defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/dictobject.c:3659:17 in Objects/funcobject.c:1278:5: runtime error: call to function visit_reachable through pointer to incorrect function type 'int (*)(struct _object *, void *)' gcmodule.c:502: note: visit_reachable defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/funcobject.c:1278:5 in
Open Graph Description: Because many other changes are likely needed for gh-111178, I have opened this PR separately for review by the respective codeowner. The error for visit_reachable() might be the most common one I e...
X Description: Because many other changes are likely needed for gh-111178, I have opened this PR separately for review by the respective codeowner. The error for visit_reachable() might be the most common one I e...
Opengraph URL: https://github.com/python/cpython/pull/112687
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:61a4c003-59ea-4776-fae9-2954362a4de9 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8554:CF40E:DA9B34:12E2BCB:696A8D39 |
| html-safe-nonce | a89002a013478810e022053d4f9493d415ecfe9469b07f8cb4af00101a688986 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTU0OkNGNDBFOkRBOUIzNDoxMkUyQkNCOjY5NkE4RDM5IiwidmlzaXRvcl9pZCI6IjQ0NjgzNzAzOTE4MjE4ODA2MzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bca350dfa060457913f3b1184b3906527346f9a45f00de480a36e432f3f4154c |
| hovercard-subject-tag | pull_request:1627643924 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/112687/files |
| twitter:image | https://avatars.githubusercontent.com/u/7941193?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/7941193?s=400&v=4 |
| og:image:alt | Because many other changes are likely needed for gh-111178, I have opened this PR separately for review by the respective codeowner. The error for visit_reachable() might be the most common one I e... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | d2aa6dedd7d97fa651b17c40401f2605f309df5ca5fb659bf0554cf34f1de825 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c1dbca8981c5e3d6a69bce2f1d289e732b86241d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width