fix: configure jsonconst double parser to use std::from_chars (#4360)

The problem: apparently, jsoncons uses strtod by default when parsing doubles.
On some platforms (alpine/musl) this function uses lots of stack, which potentially can lead to stack corruption.
This PR configures jsoncons to use std::from_chars that is more efficient and less stack hungry.
The single include point to consume jsoncons/json.hpp should be "core/json_object.h"

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2024-12-24 04:02:50 +02:00 committed by GitHub
parent 95cd9dfb4c
commit 01f24da2b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 19 additions and 17 deletions

View file

@ -9,12 +9,6 @@
#include <absl/strings/str_join.h>
#include <absl/strings/str_split.h>
#include <jsoncons/json.hpp>
#include <jsoncons_ext/jsonpatch/jsonpatch.hpp>
#include <jsoncons_ext/jsonpath/jsonpath.hpp>
#include <jsoncons_ext/jsonpointer/jsonpointer.hpp>
#include <jsoncons_ext/mergepatch/mergepatch.hpp>
#include "absl/cleanup/cleanup.h"
#include "base/flags.h"
#include "base/logging.h"
@ -36,6 +30,12 @@
#include "server/tiered_storage.h"
#include "server/transaction.h"
// clang-format off
#include <jsoncons_ext/jsonpatch/jsonpatch.hpp>
#include <jsoncons_ext/jsonpointer/jsonpointer.hpp>
#include <jsoncons_ext/mergepatch/mergepatch.hpp>
// clang-format on
ABSL_FLAG(bool, jsonpathv2, true,
"If true uses Dragonfly jsonpath implementation, "
"otherwise uses legacy jsoncons implementation.");