Segmentation fault when try to add server gRPC cpp to server
Posted: 08 Mar 2023, 14:11
OS: Red Hat Enterprise Linux release 8.7 (Ootpa)
C++ OPC UA SDK: uasdkcppbundle-src-debian9.3-x86_64-gcc6.3.0-v1.7.6-537
OpenSSL 1.1.1k FIPS 25 Mar 2021
I create a server upon C++ OPC UA SDK.
It work fine.
But when I try to add gRPC server in OPC UA server to update NodeIDs, there is a segmentation fault:
Starting program: /home/user/myserver-opcua/sdk/bin/uaservercppd
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff7fe0700 (LWP 17748)]
[New Thread 0x7ffff5b7d700 (LWP 17749)]
[New Thread 0x7ffff5a7c700 (LWP 17750)]
[New Thread 0x7ffff597b700 (LWP 17751)]
[New Thread 0x7ffff587a700 (LWP 17752)]
[New Thread 0x7ffff5779700 (LWP 17753)]
[New Thread 0x7ffff5678700 (LWP 17754)]
[New Thread 0x7ffff5577700 (LWP 17755)]
[New Thread 0x7ffff5476700 (LWP 17756)]
[New Thread 0x7ffff5375700 (LWP 17757)]
[New Thread 0x7ffff5274700 (LWP 17758)]
[New Thread 0x7ffff5173700 (LWP 17759)]
[New Thread 0x7ffff5072700 (LWP 17760)]
[New Thread 0x7ffff4f71700 (LWP 17761)]
Thread 1 "uaservercppd" received signal SIGSEGV, Segmentation fault.
0x0000000001479ed6 in CRYPTO_refcount_inc ()
Missing separate debuginfos, use: yum debuginfo-install glibc-2.28-211.0.1.el8.x86_64 libgcc-8.5.0-16.0.2.el8_7.x86_64 libstdc++-8.5.0-16.0.2.el8_7.x86_64 libxml2-2.9.7-15.el8_7.1.x86_64 openssl-libs-1.1.1k-7.el8_6.x86_64 xz-libs-5.2.4-4.el8_6.x86_64
(gdb) bt
#0 0x0000000001479ed6 in CRYPTO_refcount_inc ()
#1 0x000000000146078c in RSA_up_ref ()
#2 0x0000000001411254 in EVP_PKEY_get1_RSA ()
#3 0x0000000000cd34f4 in OpcUa_P_OpenSSL_RSA_LoadPrivateKey (a_pLoadHandle=0x1cbbcc0, a_eKeyFormat=OpcUa_Crypto_Encoding_PEM, a_pCredentials=0x7fffffffd080, a_pPrivateKey=0x1ccb0f8)
at /home/user/myserver-opcua/sdk/src/uastack/platforms/linux/opcua_p_openssl_rsa.c:242
#4 0x0000000000be1277 in UaPkiProvider::loadPrivateKey (this=0x1f6f370, sPrivateKeyName=..., fileFormat=OpcUa_Crypto_Encoding_PEM, sPassword=..., pKey=0x1ccb0f8) at /home/user/myserver-opcua/sdk/src/uabase/uabasecpp/uapkiprovider.cpp:244
#5 0x0000000000b8f797 in CertificateConfiguration::loadCertificate (this=0x1ccb0b0, sPassword=..., sError=...) at /home/user/myserver-opcua/sdk/src/uabase/uapkicpp/certificateconfiguration.cpp:226
#6 0x00000000009c5cf4 in UaEndpoint::loadCertificate (this=0x20d6610) at /home/user/myserver-opcua/sdk/src/uaserver/uaservercpp/coremodule/uaendpoint.cpp:662
#7 0x000000000074c1f3 in UaServer::openEndpoint (this=0x1cc7d00, pEndpoint=0x20d6610) at /home/user/myserver-opcua/sdk/src/uaserver/uaservercpp/uamodule/uaserver.cpp:902
#8 0x000000000074b2dd in UaServer::startUp (this=0x1cc7d00, pServerManager=0x1c70610) at /home/user/myserver-opcua/sdk/src/uaserver/uaservercpp/uamodule/uaserver.cpp:659
#9 0x000000000073f513 in UaModule::startUp (this=0x1c77cb0, pCoreModule=0x1c77200) at /home/user/myserver-opcua/sdk/src/uaserver/uaservercpp/uamodule/uamodule.cpp:185
#10 0x00000000006f155f in UaServerApplication::afterStartUp (this=0x1c70430) at /home/user/myserver-opcua/sdk/src/uaserver/uaservercpp/uamodule/uaserverapplication.cpp:223
#11 0x0000000000655c7c in OpcServer::afterStartUp (this=0x1c70430) at /home/user/myserver-opcua/sdk/examples/utilities/opcserver.cpp:59
#12 0x00000000009c23d8 in UaCoreServerApplication::start (this=0x1c70430) at /home/user/myserver-opcua/sdk/src/uaserver/uaservercpp/coremodule/uacoreserverapplication.cpp:722
#13 0x000000000064c637 in OpcServerMain (szAppPath=0x1c6e3d0 "/home/user/myserver-opcua/sdk/bin", szConfigFileName=0x0) at /home/user/myserver-opcua/sdk/examples/server_cpp_demo/servermain.cpp:258
#14 0x000000000064cfc6 in main (argc=1, argv=0x7fffffffde98) at /home/user/myserver-opcua/sdk/examples/server_cpp_demo/servermain.cpp:427
(gdb)
I add to SDK cmake, requirement of gRPC cmake.
Could this be a "static initialization order fiasco"?
Any idea?
Thank's for your help
C++ OPC UA SDK: uasdkcppbundle-src-debian9.3-x86_64-gcc6.3.0-v1.7.6-537
OpenSSL 1.1.1k FIPS 25 Mar 2021
I create a server upon C++ OPC UA SDK.
It work fine.
But when I try to add gRPC server in OPC UA server to update NodeIDs, there is a segmentation fault:
Starting program: /home/user/myserver-opcua/sdk/bin/uaservercppd
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff7fe0700 (LWP 17748)]
[New Thread 0x7ffff5b7d700 (LWP 17749)]
[New Thread 0x7ffff5a7c700 (LWP 17750)]
[New Thread 0x7ffff597b700 (LWP 17751)]
[New Thread 0x7ffff587a700 (LWP 17752)]
[New Thread 0x7ffff5779700 (LWP 17753)]
[New Thread 0x7ffff5678700 (LWP 17754)]
[New Thread 0x7ffff5577700 (LWP 17755)]
[New Thread 0x7ffff5476700 (LWP 17756)]
[New Thread 0x7ffff5375700 (LWP 17757)]
[New Thread 0x7ffff5274700 (LWP 17758)]
[New Thread 0x7ffff5173700 (LWP 17759)]
[New Thread 0x7ffff5072700 (LWP 17760)]
[New Thread 0x7ffff4f71700 (LWP 17761)]
Thread 1 "uaservercppd" received signal SIGSEGV, Segmentation fault.
0x0000000001479ed6 in CRYPTO_refcount_inc ()
Missing separate debuginfos, use: yum debuginfo-install glibc-2.28-211.0.1.el8.x86_64 libgcc-8.5.0-16.0.2.el8_7.x86_64 libstdc++-8.5.0-16.0.2.el8_7.x86_64 libxml2-2.9.7-15.el8_7.1.x86_64 openssl-libs-1.1.1k-7.el8_6.x86_64 xz-libs-5.2.4-4.el8_6.x86_64
(gdb) bt
#0 0x0000000001479ed6 in CRYPTO_refcount_inc ()
#1 0x000000000146078c in RSA_up_ref ()
#2 0x0000000001411254 in EVP_PKEY_get1_RSA ()
#3 0x0000000000cd34f4 in OpcUa_P_OpenSSL_RSA_LoadPrivateKey (a_pLoadHandle=0x1cbbcc0, a_eKeyFormat=OpcUa_Crypto_Encoding_PEM, a_pCredentials=0x7fffffffd080, a_pPrivateKey=0x1ccb0f8)
at /home/user/myserver-opcua/sdk/src/uastack/platforms/linux/opcua_p_openssl_rsa.c:242
#4 0x0000000000be1277 in UaPkiProvider::loadPrivateKey (this=0x1f6f370, sPrivateKeyName=..., fileFormat=OpcUa_Crypto_Encoding_PEM, sPassword=..., pKey=0x1ccb0f8) at /home/user/myserver-opcua/sdk/src/uabase/uabasecpp/uapkiprovider.cpp:244
#5 0x0000000000b8f797 in CertificateConfiguration::loadCertificate (this=0x1ccb0b0, sPassword=..., sError=...) at /home/user/myserver-opcua/sdk/src/uabase/uapkicpp/certificateconfiguration.cpp:226
#6 0x00000000009c5cf4 in UaEndpoint::loadCertificate (this=0x20d6610) at /home/user/myserver-opcua/sdk/src/uaserver/uaservercpp/coremodule/uaendpoint.cpp:662
#7 0x000000000074c1f3 in UaServer::openEndpoint (this=0x1cc7d00, pEndpoint=0x20d6610) at /home/user/myserver-opcua/sdk/src/uaserver/uaservercpp/uamodule/uaserver.cpp:902
#8 0x000000000074b2dd in UaServer::startUp (this=0x1cc7d00, pServerManager=0x1c70610) at /home/user/myserver-opcua/sdk/src/uaserver/uaservercpp/uamodule/uaserver.cpp:659
#9 0x000000000073f513 in UaModule::startUp (this=0x1c77cb0, pCoreModule=0x1c77200) at /home/user/myserver-opcua/sdk/src/uaserver/uaservercpp/uamodule/uamodule.cpp:185
#10 0x00000000006f155f in UaServerApplication::afterStartUp (this=0x1c70430) at /home/user/myserver-opcua/sdk/src/uaserver/uaservercpp/uamodule/uaserverapplication.cpp:223
#11 0x0000000000655c7c in OpcServer::afterStartUp (this=0x1c70430) at /home/user/myserver-opcua/sdk/examples/utilities/opcserver.cpp:59
#12 0x00000000009c23d8 in UaCoreServerApplication::start (this=0x1c70430) at /home/user/myserver-opcua/sdk/src/uaserver/uaservercpp/coremodule/uacoreserverapplication.cpp:722
#13 0x000000000064c637 in OpcServerMain (szAppPath=0x1c6e3d0 "/home/user/myserver-opcua/sdk/bin", szConfigFileName=0x0) at /home/user/myserver-opcua/sdk/examples/server_cpp_demo/servermain.cpp:258
#14 0x000000000064cfc6 in main (argc=1, argv=0x7fffffffde98) at /home/user/myserver-opcua/sdk/examples/server_cpp_demo/servermain.cpp:427
(gdb)
I add to SDK cmake, requirement of gRPC cmake.
Could this be a "static initialization order fiasco"?
Any idea?
Thank's for your help