cancel
Showing results for 
Search instead for 
Did you mean: 

C++: DataLayer library crashes when including httplibrary

AlexStepanov
Member

C++: DataLayer library crashes when including httplibrary

Hello,

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: https://github.com/yhirose/cpp-httplib

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 split.py script from the github project, I could split the httplib.h file into a httplib.cc 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 libcomm_datalayer.so:

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

Including the new httplib.h file (after splitting it with split.py) 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)
5 REPLIES 5
CodeShepherd
Contributor

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?

AlexStepanov
Member

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?

CodeShepherd
Contributor

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

I could have a look in the log files that are part of the system report what the messages out of the snap are. But as it is working at your side it will be not that relevant then.

I will do the tests with tcp connection also and come back here later on.

Please make sure when using the tcp connection that user name and password have to fit to your controller. Some time we see that this is changed in the user management but not in the connection settings snaps. EDIT: Same for the IP address of the control.

CodeShepherd
Contributor

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

I could now also reproduce a crash when using the TCP connection and adding the httlib.h to the project. We are now further investigating this issue. Thanks for mentioning.

CodeShepherd
Contributor

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

The problem of crashing application when using the httplib.h will be fixed in next SDK version 1.10 coming up with RM21.07 end of July.

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist