Closed ee7 closed 3 weeks ago
I can confirm that switching to clang 17.0.6 makes c4test basic18.c4m
pass.
And with UBSan:
../src/con4m/object.c:502:13: runtime error: call to function c4m_sha_init through pointer to incorrect function type 'void (*)(void **, struct __va_list_tag *)'
/foo/libcon4m/debug/../src/con4m/crypto/sha.c:30: note: c4m_sha_init defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/con4m/object.c:502:13 in
../src/con4m/format.c:387: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 *)'
/foo/libcon4m/debug/../src/con4m/string.c:1309: note: c4m_string_format defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/con4m/format.c:387:29 in
../src/con4m/object.c:590:12: runtime error: call to function c4m_str_to_str through pointer to incorrect function type 'struct c4m_str_t *(*)(void *)'
/foo/libcon4m/debug/../src/con4m/string.c:1201: note: c4m_str_to_str defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/con4m/object.c:590:12 in
info: Compiling: /foo/libcon4m/tests/basic18.c4m
../src/con4m/tree_pattern.c:292:12: runtime error: call to function tcmp through pointer to incorrect function type 'bool (*)(void *, void *)'
/foo/libcon4m/debug/../src/con4m/compiler/ast_utils.c:6: note: tcmp defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/con4m/tree_pattern.c:292:12 in
../src/hatrack/hash/set.c:251:15: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/stdlib.h:971:30: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/hatrack/hash/set.c:251:15 in
../src/con4m/box.c:40:12: runtime error: call to function i64_fmt through pointer to incorrect function type 'struct c4m_str_t *(*)(void *, struct c4m_fmt_spec_t *)'
/foo/libcon4m/debug/../src/con4m/numbers.c:698: note: i64_fmt defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/con4m/box.c:40:12 in
warning: /foo/libcon4m/tests/basic18.c4m:17:5: Variable i is explicitly declared, but not used.
(def_without_use)
info: Done processing: /foo/libcon4m/tests/basic18.c4m
../src/con4m/marshal.c:267: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 *)'
/foo/libcon4m/debug/../src/con4m/string.c:1126: note: c4m_string_marshal defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/con4m/marshal.c:267:5 in
../src/con4m/marshal.c:349:5: runtime error: call to function c4m_string_unmarshal through pointer to incorrect function type 'void (*)(void *, c4m_stream_t *, struct hatrack_dict_t *)'
/foo/libcon4m/debug/../src/con4m/string.c:1148: note: c4m_string_unmarshal defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/con4m/marshal.c:349:5 in
****STARTING PROGRAM EXECUTION*****
../src/con4m/object.c:539:12: runtime error: call to function signed_repr through pointer to incorrect function type 'struct c4m_str_t *(*)(void *)'
/foo/libcon4m/debug/../src/con4m/numbers.c:22: note: signed_repr defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/con4m/object.c:539:12 in
(1, 2, "three", 4, 100)
(1, 2, "three", 4, 100)
(100, 4, "three", 2, 1)
../src/con4m/object.c:718:5: runtime error: call to function c4m_tuple_set through pointer to incorrect function type 'void (*)(void *, void *, void *)'
/foo/libcon4m/debug/../src/con4m/tuple.c:26: note: c4m_tuple_set defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/con4m/object.c:718:5 in
../src/con4m/object.c:704:12: runtime error: call to function c4m_tuple_get through pointer to incorrect function type 'void *(*)(void *, void *)'
/foo/libcon4m/debug/../src/con4m/tuple.c:32: note: c4m_tuple_get defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/con4m/object.c:704:12 in
42
three
****PROGRAM EXECUTION FINISHED*****
Passed 1 out of 1 run tests.
Related:
With:
We see a segfault with
basic18.c4m
(added by https://github.com/crashappsec/libcon4m/commit/9e41c6cd27e400a6ffe422c1af5e320d9329330f):and after enabling ASan:
Memcheck output: