rclcpp::init crashes the node if i include certain header files from freeopcua library
My node was working fine with ros2 dashing. When i upgraded to ros2 foxy, if i include certain header files from freeOPCUA library (ex. client.h) my node crashes at rclcpp::init(argc, argv)
The prompt doesn't show many details, it just shows exit code -11. It crashes even if i just add the header file and not link any .so files or not use any functions from the library. If i chose to use the library, i can use the library functions just fine before rclcpp::init. And of course if i don't include these header files, rclcpp::init doesn't crash.
I tried to put rclcpp::init in a try catch block to catch the exceptions. but to my surprise, even if it is in try block, the program still crashes. There is no issue while compiling and as i mentioned before, everything works fine in dashing.
Asked by apoorvcn47 on 2020-09-24 09:00:28 UTC
Answers
You were right sir. Both FreeOPCUA and ROS use different version of spdlogger. I edited some files in OPCUA to use system spdlogger and it worked
So, this issue was already raised on FreeOPCUA github page. The necessary commits are available but haven't been merged yet. Please go through following links for help https://github.com/FreeOpcUa/freeopcua/issues/352 https://github.com/FreeOpcUa/freeopcua/pull/356/commits/8f0bd3b0adf4c7b128f9928178d0db5b7c43a805 https://github.com/FreeOpcUa/freeopcua/pull/356/commits/958936037d9595806f8a5617f94850cd81463b2b
Asked by apoorvcn47 on 2020-09-25 13:21:27 UTC
Comments
I edited some files in OPCUA
It would be immensely valuable if you could detail which files you've edited, and how.
Asked by gvdhoorn on 2020-09-25 14:33:15 UTC
Updated my answer
Asked by apoorvcn47 on 2020-09-25 15:03:40 UTC
Comments
A possible cause for these kinds of problems is a symbol clash, where two different libraries define the same symbol in some shared namespace but use it differently or have different assumptions. This could even be caused by a symbol declared in a header. You wouldn't need to actually link to anything.
Whether that is the cause here I couldn't say. Just thought I'd mention this.
It's likely the binary is actually crashing. In that case, there are no exceptions to catch.
I would suggest you copy-paste the errors you see into your question (do not post a screenshot). Perhaps someone recognises them or they provide some clue as to what is going wrong.
Asked by gvdhoorn on 2020-09-24 10:50:05 UTC