Forum > QT

SIGSEGV in dynamic library with widgetsets QT5/6

(1/2) > >>

7bit:
If unit "Interface" used in the dynamic library, a SIGSEGV error occurs when unloading the library. Moreover, the error occurs if you load the library dynamically with the LoadLibrary function. Most likely, there is a failure in unit "Interface" when calling FreeWidgetset in the finalization section. There is no such problem with GTK2 and Win32 widgets. I made an example. Even the simplest library causes a crash. What could be the problem?

Lazarus 4.3 (rev lazarus_4_2-26-g44b59001af) FPC 3.2.3 x86_64-linux-qt5

qt5pas version 2.16.4

7bit:
The queue doesn't even reach FreeWidgetSet. The error occurs when calling QWidget_WindowTitle(Widget, Str). And if you try to skip this call by adding TQtMainWindow.getText Exit(") to the method, then the error occurs already in QWidget_hide(Widget).

If you link the library to the program statically (via external) without calling LoadLibrary, then everything works fine.

7bit:
I started looking for what in the "Interface" module could be the source of the error. I did all the manipulations for the dynamic library, but the code in the application itself remained unchanged. First, in this module, I commented out the lines in the initialization and finalization sections - there was an error anyway. Eventually I got to the qt56 module and in it I commented out the initPWideStrings call. As a result, the test application with LoadLibrary and FreeLibrary calls terminated without errors.  Interestingly, now when linking the library statically, an error began to occur when launching the application: The Project1 project called the exception class 'External: SIGSEGV'. I'm at a loss.

cdbc:
Hi
It gets worse with Qt6. Below is the output in a terminal, when I run one of my test-apps from there:
--- Code: Bash  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---bc@red svc-view-via-plim [test]$ ./testplimviewQObject::installEventFilter(): Cannot filter events for objects in a different thread.QObject: Cannot create children for a parent that is in a different thread.(Parent is QClipboard(0x1643cf0), parent's thread is QThread(0x145ebd0), current thread is QThread(0x7f023c003b00)QObject::startTimer: Timers can only be used with threads started with QThreadQObject::installEventFilter(): Cannot filter events for objects in a different thread.Segmentfejl                ./testplimviewbc@red svc-view-via-plim [test]$ I haven't fiddled with the code in qt62pas.
Run from the GUI I don't see these errors / hints...

--- Quote ---Eventually I got to the qt56 module and in it I commented out the initPWideStrings call.
--- End quote ---
I don't think you can do that, because Qt uses unicodestrings and, at least, on Linux it needs a 'unicode-/widestring manager'...
Let's just hope @Zeljko sees this thread, as he is the maintainer of QtPasxxx
Regards Benny

7bit:

--- Quote from: cdbc on October 17, 2025, 09:33:55 am ---I don't think you can do that, because Qt uses unicodestrings and, at least, on Linux it needs a 'unicode-/widestring manager'...

--- End quote ---

Yes, I understand that. I just hope this helps @Zeljko find the problem.

Navigation

[0] Message Index

[#] Next page

Go to full version