Page 1 of 1

Debug error using VS CODE

Posted: 26 May 2023, 07:50
by jorman
Hello,
After compiling my 1.7.9 version C++ SDK using VS CODE, I running the example program "server_lesson01d" in the TERMINAL provided by VS CODE like:
"user@wpserver-Precision-5820-Tower:~/share/UA/sdk/build/examples/server_gettingstarted/lesson01$ ./server_lesson01d",
but the program crashed with message:
"server_lesson01d: /home/user/share/UA/sdk/src/uabase/uabasecpp/uaplatformlayer.cpp:372: static int UaPlatformLayer::init(): Assertion `(((uStatus) & 0xC0000000) == 0x00000000)' failed.Abandon (core dumped)".
and A dialog box pops up with message “Unable to open 'raise.c': Unable to read file '/build/glibc-OTsEL5/glibc-2.27/sysdeps/unix/sysv/linux/raise.c' (Error: Unable to resolve non-existing file '/build/glibc-OTsEL5/glibc-2.27/sysdeps/unix/sysv/linux/raise.c').”

However I running the example program in the Terminal provided by Ubuntu, it works well.

Then I debug the program using Debugger provided by VS CODE, the message above still appears, and the CALL STACK show like this:
libc.so.6!__GI_raise(int sig) (/build/glibc-OTsEL5/glibc-2.27/sysdeps/unix/sysv/linux/raise.c:51)
libc.so.6!__GI_abort() (/build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:79)
libc.so.6!__assert_fail_base(const char * fmt, const char * assertion, const char * file, unsigned int line, const char * function) (/build/glibc-OTsEL5/glibc-2.27/assert/assert.c:92)
libc.so.6!__GI___assert_fail(const char * assertion, const char * file, unsigned int line, const char * function) (/build/glibc-OTsEL5/glibc-2.27/assert/assert.c:101)
UaPlatformLayer::init() (/home/user/share/UA/sdk/src/uabase/uabasecpp/uaplatformlayer.cpp:372)
OpcServerMain(const char * szAppPath) (/home/user/share/UA/sdk/examples/server_gettingstarted/lesson01/servermain.cpp:49)
main() (/home/user/share/UA/sdk/examples/server_gettingstarted/lesson01/servermain.cpp:141)

Do you know how to fix this?

Re: Debug error using VS CODE

Posted: 30 May 2023, 13:10
by Support Team
Hi,

the best way to analyze is:
> debug into the stack initialization and see what causes the assert (the assert is just there to inform you on potential configuration error).

The most educated guess we have is:
Your system (when using VS Code) allows file descriptors larger than FD_SETSIZE. This may lead to memory corruption in your application when exceeding the limit later during runtime (socket handle is file descriptor). For that reason it is important to think about correct FD_SETSIZE, depending on your target system and your use case, and to set your rlimit accordingly (ulimit -n).

Re: Debug error using VS CODE

Posted: 31 May 2023, 03:03
by jorman
Hello,

Yes,you are right.
I comment out the relevant lines in the CMakeLists.txt inside "sdk/src/uastack", around line 236 "add_definitions(-DUASTACK_FD_SETSIZE=65536)"
then the program run well.

Thank you very much.