I am trying to read a json file using the library nlohmann-json. My code is the following:
nlohmann::json Parameters = nlohmann::json::parse(param_file);
Which throws the following error:
libc++abi: terminating with uncaught exception of type cling::InvalidDerefException: Trying to access a pointer that points to an invalid memory address.
I do not know if it is relevant, but when trying to include nlohmann-json I first tried with:
But root did not recognize it, so I had to install the library separately and write the full path to the library location.
Thanks in advance.
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.28/06
Platform: macOS Monterrey 12.6.3
Compiler: Not Provided
Maybe add after this line, for security:
But tI do want to read the file, so the execution of that line is needed.
That lines adds a security: if the file name is incorrect or not found, it will exit instead of crashing. So you have to fix the filename or path so that it finds it correctly.
Actually, the file is found correctly (
true so I believe the issue must be coming from the nlohmann-json library.
Mmm maybe try to share the json file with us, or try to debug it yourself with:
If you’ve ever rubbed your eyes trying to decrypt C++ compilation errors from a terminal, or even have faced with your bare eye the intimidating logs of valgrind output for memory leak detection, or manually deployed gdb, you should definitely keep...
The content of the json file is as simple as:
I have tried to run this very same code on another laptop and it does work, so I guess it might be related to the ROOT installation. By the way, I am not allowed to modified the original post anymore, but there is a mistake with the ROOT version, it is 6.26/06.