Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-5549

UBSan: fix -fsanitize=function runtime errors with Clang 17 and newer

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • C Drivers

      According to python/cython issue 111178, Clang 17 introduced support for the -fsanitize=function check for the C language (previously only supported for C++). More context and discussions in openssl/openssl issue 22896.

      Compiling the C Driver with Clang 17 or newer and UBSan enabled reveals several instances of undefined behavior due to invoking functions via a pointer with incorrect function type. These instances are both in library code and test code.

      As most (all?) of these instances involve internal callback pointers/functions, these runtime errors can be easily addressed without affecting the API or ABI by using an intermediate internal function with the correct function type for the callback pointers that invokes the target function within their definition.

            Assignee:
            ezra.chung@mongodb.com Ezra Chung
            Reporter:
            ezra.chung@mongodb.com Ezra Chung
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: