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

GCC-14 gives bounds-strict error in libbson

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.30.2
    • Affects Version/s: None
    • Component/s: libbson
    • None
    • Not Needed
    • None
    • C Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      _Downstream issue: https://github.com/jeroen/mongolite/issues/269_

      The R bindings are showing an ASAN error in GCC-14. The stack trace shows the problem is in jsonsl.c:

       

      > library(mongolite)
      > mongolite:::json_to_bson('{}')
      jsonsl/jsonsl.c:121:19: runtime error: index 1 out of bounds for type 'jsonsl_state_st [1]'
          #0 0x7f9caa79a48d in jsonsl_new jsonsl/jsonsl.c:121
          #1 0x7f9caa74dfad in bson_json_reader_new bson/bson-json.c:2112
          #2 0x7f9caa74f297 in bson_new_from_json bson/bson-json.c:2252
          #3 0x7f9caa5513cd in R_json_to_bson /tmp/RtmpL44AuM/R.INSTALL6ae1186e640/mongolite/src/bson.c:31

      Environment / How to Reproduce

      We use GCC-14 on Linux and compile everything with:

        CC = gcc -fsanitize=address,undefined,bounds-strict -fno-omit-frame-pointer

      And then a simple test program that invokes bson_new_from_json::

        bson_error_t err;
        bson_t b = bson_new_from_json ((uint8_t)  "{}", -1, &err);

       

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            jeroen@berkeley.edu Jeroen Ooms
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              None
              None
              None
              None