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: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.28.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • C Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      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:
              Resolved: