Orthanc Object Storage does not work due to Jsoncpp library

Hi All,

I am testing the Plugin Google Storage (https://book.orthanc-server.com/plugins/object-storage.html). I compiled the plugin from the source and ran it with Orthanc. But it’s segmentation fault. Here is my configuration

{
“Plugins” : [
“./libOrthancGoogleCloudStorage.so”
],
“GoogleCloudStorage” : {
“ServiceAccountFile”: “/path/to/googleServiceAccountFile.json”,
“BucketName”: “test-orthanc-storage-plugin”,
“RootPath”: “”, // see below
“MigrationFromFileSystemEnabled”: false, // see below
“StorageStructure”: “flat” // see below
}
}

Here are the backtraces

(gdb) run ./orthanc.json --verbose
Starting program: /home/phtran/workingspace/orthanc-testing/Orthanc ./orthanc.json --verbose
[Thread debugging using libthread_db enabled]
Using host libthread_db library “/lib/x86_64-linux-gnu/libthread_db.so.1”.
W0729 15:13:57.133464 main.cpp:1942] Orthanc version: 1.9.6
W0729 15:13:57.133620 main.cpp:1681] Performance warning: Non-release build, runtime debug assertions are turned on
I0729 15:13:57.133652 main.cpp:1974] Architecture: 64-bit, little endian
W0729 15:13:57.133884 OrthancConfiguration.cpp:66] Reading the configuration from: “./orthanc.json”
I0729 15:13:57.135776 Toolbox.cpp:1488] Setting up the ICU common data
I0729 15:13:57.632436 Toolbox.cpp:1467] Using locale: “en_US.UTF-8” for case-insensitive comparison of strings
I0729 15:13:57.632613 Toolbox.cpp:1759] OpenSSL version: OpenSSL 1.1.1k 25 Mar 2021
I0729 15:13:57.633015 FromDcmtkBridge.cpp:291] (dicom) Using DCTMK version: 366
I0729 15:13:57.633074 FromDcmtkBridge.cpp:299] (dicom) Loading the embedded dictionaries
I0729 15:13:57.650383 FromDcmtkBridge.cpp:311] (dicom) Loading the embedded dictionary of private tags
I0729 15:13:57.662279 FromDcmtkBridge.cpp:2293] (dicom) Registering JPEG Lossless codecs in DCMTK
I0729 15:13:57.662365 FromDcmtkBridge.cpp:2301] (dicom) Registering JPEG codecs in DCMTK
I0729 15:13:57.662398 FromDcmtkBridge.cpp:2308] (dicom) Registering RLE codecs in DCMTK
I0729 15:13:57.662431 Enumerations.cpp:2315] Default encoding for DICOM was changed to: Latin1
W0729 15:13:57.684264 main.cpp:864] Loading plugin(s) from: ././libOrthancGoogleCloudStorage.so
W0729 15:13:59.723691 PluginsManager.cpp:269] Registering plugin ‘Google Cloud Storage’ (version mainline)

Program received signal SIGSEGV, Segmentation fault.
__GI___libc_free (mem=0x770000007c) at malloc.c:3102
3102 malloc.c: No such file or directory.
(gdb) bt
#0 __GI___libc_free (mem=0x770000007c) at malloc.c:3102
#1 0x00007ffff682719c in Json::Reader::~Reader (this=0x7fffffffbb90, _in_chrg=) at /usr/include/jsoncpp/json/reader.h:33
#2 0x00007ffff681a167 in OrthancPlugins::ReadJsonInternal (target=…, buffer=0x271f440, size=321, collectComments=true)
at /home/phtran/workingspace/orthanc-object-storage/build/google/orthanc/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp:322
#3 0x00007ffff681a23e in OrthancPlugins::ReadJson (target=…, buffer=0x271f440, size=321)
at /home/phtran/workingspace/orthanc-object-storage/build/google/orthanc/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp:358
#4 0x00007ffff681a206 in OrthancPlugins::ReadJson (target=…,
source=“{\n "GoogleCloudStorage" : {\n "BucketName" : "test-orthanc-storage-plugin",\n "MigrationFromFileSystemEnabled" : false,\n "RootPath" : "",\n "ServiceAccountFile" : "/path/to/googleSe”…)
at /home/phtran/workingspace/orthanc-object-storage/build/google/orthanc/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp:350
#5 0x00007ffff681a9f8 in OrthancPlugins::OrthancString::ToJson (this=0x7fffffffbdb8, target=…)
at /home/phtran/workingspace/orthanc-object-storage/build/google/orthanc/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp:505
#6 0x00007ffff681b269 in OrthancPlugins::OrthancConfiguration::LoadConfiguration (this=0x7fffffffbee0)
at /home/phtran/workingspace/orthanc-object-storage/build/google/orthanc/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp:633
#7 0x00007ffff681b408 in OrthancPlugins::OrthancConfiguration::OrthancConfiguration (this=0x7fffffffbee0)
at /home/phtran/workingspace/orthanc-object-storage/build/google/orthanc/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp:645
#8 0x00007ffff67fe1d6 in OrthancPluginInitialize (context=0x272c470)
at /home/phtran/workingspace/orthanc-object-storage/Common/StoragePlugin.cpp:315
#9 0x0000000000a4c982 in Orthanc::CallInitialize (plugin=…, context=…)
at /media/second-drive/BuildBotWorker/Orthanc_1_9_6
-_LSB_Debug/build/OrthancServer/Plugins/Engine/PluginsManager.cpp:98
#10 0x0000000000a4dbc4 in Orthanc::PluginsManager::RegisterPlugin (this=0x2958a40, Python Exception <class ‘gdb.error’> No type named class std::basic_string<char, std::char_traits, std::allocator >::Rep.:
path=)
at /media/second-drive/BuildBotWorker/Orthanc_1_9_6
-LSB_Debug/build/OrthancServer/Plugins/Engine/PluginsManager.cpp:272
#11 0x00000000008b64c9 in LoadPlugins (plugins=…)
at /media/second-drive/BuildBotWorker/Orthanc_1_9_6
-LSB_Debug/build/OrthancServer/Sources/main.cpp:865
#12 0x00000000008bbce0 in ConfigurePlugins (argc=3, argv=0x7fffffffde38, upgradeDatabase=false, loadJobsFromDatabase=true)
at /media/second-drive/BuildBotWorker/Orthanc_1_9_6
-LSB_Debug/build/OrthancServer/Sources/main.cpp:1605
#13 0x00000000008bbfa0 in StartOrthanc (argc=3, argv=0x7fffffffde38, upgradeDatabase=false, loadJobsFromDatabase=true)
at /media/second-drive/BuildBotWorker/Orthanc_1_9_6
-_LSB_Debug/build/OrthancServer/Sources/main.cpp:1658
#14 0x00000000008bceeb in main (argc=3, argv=0x7fffffffde38)

This is indeed error from jsoncpp when it’s just declared in OrthancPluginCppWrapper.cpp, line 322

static bool ReadJsonInternal(Json::Value& target,
const void* buffer,
size_t size,
bool collectComments)
{
#if JSONCPP_USE_DEPRECATED == 1
Json::Reader reader;
return reader.parse(reinterpret_cast<const char*>(buffer),
reinterpret_cast<const char*>(buffer) + size, target, collectComments);
#else

Can you please help to check whether you are using the jsoncpp version correct ?
Thanks,
Chris

I manged to use this plugin by compiling Orthanc by myself instead of using Orthanc binary downloaded from lsb page. So please ignore this thread. Thanks

Hello,

For reference, I have just committed a changeset that allows a LSB build (Linux Standard Base) of Orthanc to load a non-LSB plugin:
https://hg.orthanc-server.com/orthanc/rev/31e12d2ce275

In Orthanc <= 1.9.6, the LSB binaries of the main Orthanc executable (as downloaded from https://lsb.orthanc-server.com/orthanc/) will most likely segfault if loading a non-LSB plugin.

This improvement will be part of forthcoming release 1.9.7 of Orthanc.

Sébastien-