Showing results for 
Search instead for 
Did you mean: 

C++: DataLayer library crashes when including httplibrary


C++: DataLayer library crashes when including httplibrary


I would like to write and read data from the DataLayer and also provide a user interface through the browser for configuration of the app.

I'm using the following HTTP Library:

Now I face the following problem: When creating a datalayer node and including the httplib.h file, the snap app crashes.

The minimal example I could recreate, was to use the datalayer.register.node sample and just put a

#include "httplib.h"

 at the top of the main.cpp file (and also put the httplib.h file next to the main.cpp). Building the sample works, but when the app starts it crashes (seg faults) directly.
I did not put any additional code, only the include. All classes and methods are behind namespaces. I also tried to rename all defines to be unique, but the crash did not change. The crash occurs during the start() of the provider.

Using the script from the github project, I could split the httplib.h file into a and httplib.h, than I created a shared libary. Now when I build the project and link against the shared library (and also starting a http server serving a simple site), the app crashes when an access over http occurs. With this setup I also saw the message, that the segfault occured in the

appname[27000]: segfault at 15 ip 00007f5d16e98184 sp 00007f5d06ffbee0 error 4 in[7f5d16d97000+25f000] 

Including the new httplib.h file (after splitting it with worked fine, so the includes and defines from httplib.h are not the culprit. 

Do I need to configure the sockets from the httplib library in some specific way to not to conflict with the datalayer sockets? 

Tags (3)

Re: C++: DataLayer library crashes when including httplibrary

I tried to reproduce your errors but could not in my case (withyour minimal example) everthing works just fine. See my snaps attached.

Which version of the system (please make a system report via "About -> Generate Report") and the SDK are you using?


Re: C++: DataLayer library crashes when including httplibrary

Thank you very much!

From your snap I saw that you are using the IPC connection (DL_IPC_AUTO) instead of "tcp://...". With DL_IPC_AUTO everything seems to work fine. But with "tcp://..." the above crashes occure.

Thus I will be using DL_IPC_AUTO.

I'm using the SDK Version 1.8.0 RM21.07 and CtrlX Works 1.8.1. Do you still need the system report?