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);