Getting SIGSEGV when using external lib after upgrade to Qt 6.4
-
Hi there everyone,
I am currently upgrading my application from Qt 5.15.2 to 6.4.2. The application uses an external library c_static.lib made by Kx from here. After the upgrade to 6.4.2, the application builds without any issues. However, when I run it, it crashes at the very first line where we use a function from c_static.lib. It crashes with a SIGSEGV error. I don't have any visibility into the source of the lib and have asked about it in the Kx forum here but had no replies. I'm still unsure if the issue is with the lib or Qt but, given that the lib works fine in Qt 5.15.2, I was hoping someone may be able to help here.
This is the configuration we currently use (and the lib works fine)
And this is the configuration I want to upgrade to (crashes with SIGSEGV when I use the lib)
Thank you in advance for your help!
-
@odriscog said in Getting SIGSEGV when using external lib after upgrade to Qt 6.4:
SIGSEGV
Could be invalid pointer. Please show your code where this happens.
-
Hi there,
Thank you for your reply. The crash happens in my code when I use the method
ktn(KS, 0)
which is declared in the k.h file here. I think the definition is in the c_static lib here. I've asked the Kx community about the issue but had no replies and just wanted to ask here in case anyone could help.
Thank you
-
When I created a new project to test just this library in isolation, I get the same issue.
QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++17 QMAKE_CXXFLAGS += -DKXVER=3 -std=c++17 -O3 -Wno-missing-field-initializers QMAKE_CXXFLAGS_RELEASE -= -O3 WIN_KX_INSTALL = $$(USERPROFILE)/code/kx win32: INCLUDEPATH += $${WIN_KX_INSTALL}/h/ win32: HEADERS += $${WIN_KX_INSTALL}/h/k.h win32: LIBS += -L$${WIN_KX_INSTALL}/lib/ -lc_static -lws2_32 -liphlpapi SOURCES += \ main.cpp
main.cpp
#include "k.h" int main(int argc, char *argv[]) { K test = ktn(KS, 0); }
When I build and run this using Qt 5.15.2, it works fine but it crashes with SIGSEGV when I build and run using Qt 6.4.2 (as per the kit configurations shown in my original post)
Thank you!
-
Are you sure the provided precompiled library is compatible with MinGW? Looks like it's a MSVC library sind it's file prefix is
.lib
and not.a
. Or is it a plain c library? But even then there might by differences e.g. due to c++17 compiler flag or others. -
Hi there Christian,
This is a really helpful suggestion for me to look into thank you. We have always used MinGW for our project as we need to compile for both Windows and Linux and I was told MinGW would make this easier thank MSVC. I am happy to be corrected if that is not the case!
The full set of Linux, MacOS and Windows libs which are provided by Kx can be found here. I don't see any .a libraries there, just .lib. Does that mean we should strictly be using MSVC with these libs?
Another update on the issue I am having:
I wondered whether the different MinGW version might be the cause of the crashes I was seeing. The Qt wiki outlines the version of MinGW used included in each version here. I tried to build our project in Qt 6.2.1 as it uses the same MinGW version as Qt 5.15.2 (which runs our project just fine). The project builds and runs perfectly on Qt 6.2.1 but fails on any later version. So I'm tempted to conclude the new MinGW versions are not compatible with the Kx libraries but I am at a loss to explain why.Thank you as ever!
-
@odriscog said in Getting SIGSEGV when using external lib after upgrade to Qt 6.4:
just .lib. Does that mean we should strictly be using MSVC with these libs?
Yep, that is the implication.
.lib
is the MSVC++ library file extension,.a
is the MinGW one (unless a C-only library, not C++). You cannot mix MSVC & MinGW compiled elements. Having said that, I am surprised that anything ever linked if this was the case.