0

I have an application which is linked to json-c and a third party library. This third party library is linked to libjansson library. So when I execute my application, it crashes due to memory corruption as invalid pointer.

On analysis, both the libraries have json_object_get() API which caused the weird behaviour. If I change this API name from json-c library, app working as expected.

Since I even tried with statically linked libjannson to third party library as well as statically linked json-c to app, it won't crash but still failed json-c calls.

The scenario is given below:

  • app linked to libjson_c_lib.so and libjansson_c_lib.so. Both of these are wrapper libraries on top of json-c and jannson.

  • libjson_c_so linked to libjson-c.so

  • libjansson_c.so linked to libjansson.so.

Could you please someone help here?

Vysakh A V
  • 111
  • 1
  • 11
  • 1
    C has one global namespace. I'd suggest standardizing on one of the two JSON libraries. – stark May 15 '20 at 18:17
  • We are required to use both of those libraries and we are using json-c for our purpose as it heavily used. Now we required to link a third party library but that is using another parser. Tried with statitically linking the libs but no luck. Similarly tried with version-script of flag also not worked. – Vysakh A V May 15 '20 at 19:24
  • *We are required to use both of those libraries* In ONE process? You're **required** to use both those libraries? If so, your requirements are garbage. First, actual requirements should never specify the solution, but what you need to do: "Process this JSON..." and never "Process this JSON with json-c...". Second, your requirements apparently are trying to make you do something that is not possible - link two different libraries with conflicting names into one process. There's no safe, reliable way to do that. You need to not use json-c, the third party library, or do something else. – Andrew Henle May 16 '20 at 17:16
  • @AndrewHenle absoultely this is a strange situation but we are not using both json libraries directly from my application. Here scenarion is: Application linked to a library which is internally used json-c in the librarys and we are also linked another third party library from application which is internally used jansson for their puprose. But the application required both the libraries for its functionality. Thats why we are come up with this issue. Updated an example code sceanrio we are facing. – Vysakh A V May 16 '20 at 19:09
  • "This third party library is linked to libjansson library." -- please edit your question with additional info: is 3rd-party library an archive or a DSO, or both. Does it _contain_ `libjansson` _inside_ of it, or just links against `libjansson.so` ? – Employed Russian May 17 '20 at 14:10
  • It is a shared object which linked libjannson.so. – Vysakh A V May 17 '20 at 14:22
  • @VysakhAV Did you solve your program? If yes, how did you solve it? Thank you. – EngMe Dec 03 '22 at 19:07
  • 1
    @EngMe, I was reported this to json-c and jansson handler team, and they fixed it by using versioning symbols. So probably in later versions fixed the problem. More details available here in: https://github.com/json-c/json-c/issues/621 https://github.com/akheron/jansson/issues/536 In my case, still am using older version , so I am using a tweak way as I changed the json_object_get API name in json-c library as a patch to resolve this in our case. – Vysakh A V Dec 20 '22 at 15:08

0 Answers0