未定义行为 sanitizer 的意外行为

  • Transition from Ubuntu 22 to 24 on GitHub actions: Recently started with version bumps of many applications. One such bump is for clang, which now uses clang 18 by default.
  • Daily developer life: Typically uses gcc for building local stuff out of old habits. Also has clang installed and uses a large set of alternative config setups.
  • CI jobs for curl: There are millions of build combinations. Two CI jobs build curl with clang and enable some sanitizers to run tests and avoid regressions.
  • Undefined behavior sanitizer in clang 18: Suddenly found many new problems in curl code that had been running without issues for a long time.
  • Picky function prototypes: Sanitizer now tracks function pointer prototypes precisely and verifies exact match. This may be a good idea but is considered too strict by some.
  • Example in libcurl: A function pointer defined with one prototype is made to point to a function with a different prototype, causing a mismatch complaint with the sanitizer.
  • Libcurl's fix: To avoid build breakage in CI jobs, reverted to using typedef void CURL; for CURL * type, even when building libcurl.
  • Disabling the check: Disabling the check in CI jobs is not enough as it should work for everyone using libcurl.
  • Whether it's a clang issue: Not sure if it's a clang issue as it's a feature that has existed for a while and the author has simply adapted.
  • Historic footnote: In 2016, changing the CURL type to typedef struct Curl_easy CURL; caused build errors among some users and was reverted back. Now, even the #ifdef version has been reverted.
  • Post-publish update: It's pointed out that the C standard seems to support the tool's behavior, and more discussions can be found in an OpenSSL issue.
阅读 16
0 条评论