-
Notifications
You must be signed in to change notification settings - Fork 0
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
UB: call to function through pointer to incorrect function type #56
Comments
No, won't fix. A pointer is a pointer, and in every ABI in the world a void * in a parameter can be substituted with any other pointer type. It's much more clear at the function definition site to declare the ACTUAL types. Nor am I ever going to take the pain to do all the refactoring and gory casting to make the code less clear. Please do not spend time on UB that is not actually going to lead to issues on any target platforms. |
Since Clang 17, the `-fsanitize=function` check is no longer only for C++, and the check is enabled by default by `-fsanitize=undefined`. See the list of available UBSan checks [1]. The discussion of the relevant LLVM patch [2] contains: The rationale for reporting errors is C11 6.5.2.2p9: If the function is defined with a type that is not compatible with the type (of the expression) pointed to by the expression that denotes the called function, the behavior is undefined. Suppress these UBSan errors: src/hatrack/hash/dict.c:667:16: runtime error: call to function c4m_custom_string_hash through pointer to incorrect function type '__int128 (*)(void *)' /home/runner/work/libcon4m/src/con4m/dict.c:22: note: c4m_custom_string_hash defined here src/hatrack/hash/set.c:890:16: runtime error: call to function c4m_custom_string_hash through pointer to incorrect function type '__int128 (*)(void *)' /home/runner/work/libcon4m/src/con4m/dict.c:22: note: c4m_custom_string_hash defined here src/con4m/box.c:46:12: runtime error: call to function u64_fmt through pointer to incorrect function type 'struct c4m_str_t *(*)(void *, struct c4m_fmt_spec_t *)' /home/runner/work/libcon4m/src/con4m/numbers.c:690: note: u64_fmt defined here src/con4m/collect.c:174:13: runtime error: call to function c4m_finalize_allocation through pointer to incorrect function type 'void (*)(void *)' /home/runner/work/libcon4m/src/con4m/object.c:909: note: c4m_finalize_allocation defined here src/con4m/format.c:391:29: runtime error: call to function c4m_string_format through pointer to incorrect function type 'struct c4m_str_t *(*)(void *, struct c4m_fmt_spec_t *)' /home/runner/work/libcon4m/src/con4m/string.c:1347: note: c4m_string_format defined here src/con4m/list.c:153:13: runtime error: call to function sym_cmp through pointer to incorrect function type 'bool (*)(void *, void *)' /home/runner/work/libcon4m/src/con4m/compiler/cfg.c:27: note: sym_cmp defined here src/con4m/marshal.c:269:5: runtime error: call to function c4m_string_marshal through pointer to incorrect function type 'void (*)(void *, c4m_stream_t *, struct hatrack_dict_t *, long *)' /home/runner/work/libcon4m/src/con4m/string.c:1158: note: c4m_string_marshal defined here src/con4m/marshal.c:352:5: runtime error: call to function c4m_string_unmarshal through pointer to incorrect function type 'void (*)(void *, c4m_stream_t *, struct hatrack_dict_t *)' /home/runner/work/libcon4m/src/con4m/string.c:1180: note: c4m_string_unmarshal defined here src/con4m/object.c:471:13: runtime error: call to function c4m_sha_init through pointer to incorrect function type 'void (*)(void **, struct __va_list_tag *)' /home/runner/work/libcon4m/src/con4m/crypto/sha.c:30: note: c4m_sha_init defined here src/con4m/object.c:500:12: runtime error: call to function signed_repr through pointer to incorrect function type 'struct c4m_str_t *(*)(void *)' /home/runner/work/libcon4m/src/con4m/numbers.c:22: note: signed_repr defined here src/con4m/object.c:551:12: runtime error: call to function box_repr through pointer to incorrect function type 'struct c4m_str_t *(*)(void *)' /home/runner/work/libcon4m/src/con4m/box.c:13: note: box_repr defined here src/con4m/object.c:563:12: runtime error: call to function c4m_list_copy through pointer to incorrect function type 'void *(*)(void *)' /home/runner/work/libcon4m/src/con4m/list.c:392: note: c4m_list_copy defined here src/con4m/object.c:579:12: runtime error: call to function c4m_str_copy through pointer to incorrect function type 'void *(*)(void *)' /home/runner/work/libcon4m/src/con4m/string.c:263: note: c4m_str_copy defined here src/con4m/object.c:655:12: runtime error: call to function c4m_list_len through pointer to incorrect function type 'long (*)(void *)' /home/runner/work/libcon4m/src/con4m/list.c:297: note: c4m_list_len defined here src/con4m/object.c:669:12: runtime error: call to function c4m_list_safe_get through pointer to incorrect function type 'void *(*)(void *, void *)' /home/runner/work/libcon4m/src/con4m/list.c:430: note: c4m_list_safe_get defined here src/con4m/object.c:683:5: runtime error: call to function c4m_list_set through pointer to incorrect function type 'void (*)(void *, void *, void *)' /home/runner/work/libcon4m/src/con4m/list.c:63: note: c4m_list_set defined here src/con4m/object.c:697:12: runtime error: call to function c4m_list_get_slice through pointer to incorrect function type 'void *(*)(void *, long, long)' /home/runner/work/libcon4m/src/con4m/list.c:454: note: c4m_list_get_slice defined here src/con4m/object.c:711:5: runtime error: call to function c4m_list_set_slice through pointer to incorrect function type 'void (*)(void *, long, long, void *)' /home/runner/work/libcon4m/src/con4m/list.c:500: note: c4m_list_set_slice defined here src/con4m/object.c:746:12: runtime error: call to function any_int_coerce_to through pointer to incorrect function type 'void *(*)(void *, struct c4m_type_t *)' /home/runner/work/libcon4m/src/con4m/numbers.c:393: note: any_int_coerce_to defined here src/con4m/object.c:885:37: runtime error: call to function c4m_list_view through pointer to incorrect function type 'void *(*)(void *, unsigned long *)' /home/runner/work/libcon4m/src/con4m/list.c:588: note: c4m_list_view defined here src/con4m/object.c:904:12: runtime error: call to function c4m_to_list_lit through pointer to incorrect function type 'void *(*)(struct c4m_type_t *, c4m_list_t *, struct c4m_str_t *)' /home/runner/work/libcon4m/src/con4m/list.c:613: note: c4m_to_list_lit defined here src/con4m/tree_pattern.c:292:12: runtime error: call to function c4m_tcmp through pointer to incorrect function type 'bool (*)(void *, void *)' /home/runner/work/libcon4m/src/con4m/compiler/ast_utils.c:6: note: c4m_tcmp defined here Closes: #56 [1] https://releases.llvm.org/17.0.1/tools/clang/docs/UndefinedBehaviorSanitizer.html#available-checks [2] https://reviews.llvm.org/D148827
That's all fine by me. My main motivation for this ticket was to track the removal of this UBSan output, by whatever means, so that the rest of the output is more visible. In the meantime, we've gained the I'll take the liberty of re-opening this ticket, and creating #86 to close it. Please yell at me if you object. |
With:
Since Clang 17, the
-fsanitize=function
check is no longer only for C++, and the check is enabled by default by-fsanitize=undefined
. See the list of available UBSan checks and the discussion of the relevant LLVM patch, which contains:The errors of this kind that are produced when running the tests, sorted by file name:
The text was updated successfully, but these errors were encountered: