Debug error using VS CODE

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

Locked
jorman
Jr. Member
Jr. Member
Posts: 2
Joined: 24 May 2023, 02:21

Debug error using VS CODE

Post 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?

User avatar
Support Team
Hero Member
Hero Member
Posts: 3064
Joined: 18 Mar 2011, 15:09

Re: Debug error using VS CODE

Post 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).
Best regards
Unified Automation Support Team

jorman
Jr. Member
Jr. Member
Posts: 2
Joined: 24 May 2023, 02:21

Re: Debug error using VS CODE

Post 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.

Locked