Picture of Wim 4127
Registered 6 years 310 days
Wim 4127 Monday, 18 May 2020, 07:20 AM
Segmentation fault while running the application
When running the application from Visual Studio, I get a segmentation fault when calling the Log function of the AppInstance object. See attached screenshot. First thought it was caused by use of std string, but, then tried without that, than also without logger wrapper class, but even when calling "log" directly on the app object, it still end in a segmentation fault. Below output from debug window.
Extra info: SrapsConnector is a class that is instantiated in the constructor of the App class, thus this instance is certainly alive and not deleted. The function (you see in the screenshot with the fault) is called from within a JsonApi::Message function that is running on the Appwebsocket.

shellexec 1.0
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
$ =thread-group-added,id="i1"
GNU gdb (GDB) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-buildroot-linux-gnueabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
=cmd-param-changed,param="pagination",value="off"
(gdb) 1009-break-insert -f main
Stopped due to shared library event (no libraries added or removed)
Loaded '/lib/ld-linux.so.3'. Symbols loaded.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Stopped due to shared library event:
 Inferior loaded /lib/libpthread.so.0
 /lib/libuuid.so.1
 /usr/lib/libhpdf.so
 /usr/lib/libpng16.so.16
 /usr/lib/libcap.so.2
 /lib/libpam.so.0
 /usr/lib/libcrypto.so.1.1
 /usr/lib/libssl.so.1.1
 /usr/lib/libmysqlclient.so.16
 /lib/libdl.so.2
 /usr/lib/libz.so.1
 /usr/lib/libpq.so.5
 /usr/lib/libstdc++.so.6
 /lib/libm.so.6
 /lib/libgcc_s.so.1
 /lib/libc.so.6
 /lib/libatomic.so.1
 /lib/libcrypt.so.1
Loaded '/lib/libpthread.so.0'. Symbols loaded.
Loaded '/lib/libuuid.so.1'. Symbols loaded.
Loaded '/usr/lib/libhpdf.so'. Symbols loaded.
Loaded '/usr/lib/libpng16.so.16'. Symbols loaded.
Loaded '/usr/lib/libcap.so.2'. Symbols loaded.
Loaded '/lib/libpam.so.0'. Symbols loaded.
Loaded '/usr/lib/libcrypto.so.1.1'. Symbols loaded.
Loaded '/usr/lib/libssl.so.1.1'. Symbols loaded.
Loaded '/usr/lib/libmysqlclient.so.16'. Symbols loaded.
Loaded '/lib/libdl.so.2'. Symbols loaded.
Loaded '/usr/lib/libz.so.1'. Symbols loaded.
Loaded '/usr/lib/libpq.so.5'. Symbols loaded.
Loaded '/usr/lib/libstdc++.so.6'. Symbols loaded.
Loaded '/lib/libm.so.6'. Symbols loaded.
Loaded '/lib/libgcc_s.so.1'. Symbols loaded.
Loaded '/lib/libc.so.6'. Symbols loaded.
Loaded '/lib/libatomic.so.1'. Symbols loaded.
Loaded '/lib/libcrypt.so.1'. Symbols loaded.
Breakpoint 1, main (argc=1, argv=0x7ee94d04) at main.cpp:28
(gdb) 1015-stack-list-frames 0 1000
Program received signal SIGSEGV, Segmentation fault.
0x00015580 in SrapsConnector::CheckEndPointData (this=0x0, endpoint=...) at SnomProvisioningApp/sraps/SrapsConnector.cpp:56
Segmentation fault
(gdb) 1020-var-delete var1
(gdb) 1025-var-delete var3
(gdb) 1029-var-delete var5
(gdb) 1032-var-delete var6
(gdb) 1045-var-delete var12
(gdb) 1060-var-delete var19
(gdb) 1065-var-delete var21
(gdb) 1074-var-delete var25
(gdb) 1081-var-delete var28
(gdb) 1094-var-delete var33
SegmentationFault.png

Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 179 days
Daniel Deterding (innovaphone) Monday, 18 May 2020, 07:43 AM
Re: Segmentation fault while running the application
Hi Wim,

a trap at this line can just mean that the _app pointer is not valid, either deleted or wrongly assigned (or maybe a wrong cast leading to an invalid pointer?).

I would try to call _app->Log at the point, where you assign _app to your app object and check if it works at this point and then see, what happens with either your app object or the _app pointer until this callback function.

Edit:
btw. for unconditional logging (log flag independent), you can always use debug->printf("test debug %s", "test"); at any point in your code.
This can be handy for debugging purposes.

Greetings,
Daniel
Picture of Wim 4127
Registered 6 years 310 days
Wim 4127 Monday, 18 May 2020, 07:50 AM
Re: Segmentation fault while running the application
Daniel, problem is indeed mine and even more stupid than I thought, so a mea culpa is in place here sad Guess sometimes one is looking for such a special thing he forgets to check the obvious. Sorry for bothering you... you can close/delete this topic.

Wim
← You can define your color theme preference here