bugGNU TeXmacs - Bugs: bug #60931, qtpipe issue with Qt 5.15.x ->...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #60931: qtpipe issue with Qt 5.15.x -> external plugins cause segfault

Submitter:  zongtao wang <wztdream>
Submitted:  Sat 17 Jul 2021 04:50:17 PM UTC
   
 
Category:  Editor Priority:  9 - Immediate
Item Group:  Error Status:  Fixed
Privacy:  Public Assigned to:  vdhoeven
Originator Name:  Open/Closed:  Closed
Release:  None Release: 
Fixed Release:  None Fixed Release: 
Keywords: 

Jump to the original submission

Sun 03 Sep 2023 10:24:00 AM UTC, comment #14: 

Well, thank you Juan, excellent catch! Indeed that option was the difference between cmake and autotools which resolves the issue. I have commited a fix in rev. 14200.

Philippe Joyez <pjoyez>
Group Member
Tue 08 Aug 2023 11:58:22 AM UTC, comment #13: 

Thank you very much to Philippe Joyez!

I think I have found the "reason" of this bug.

It is the option -fno-rtti passed to the compiler by autotools.

My environment: debian 12 stable (bookworm). I have followed the instructions in

https://github.com/texmacs/notes/blob/main/docs/compiling-texmacs-with-guile-3-and-qt-5-on-ubuntu-22.html

I have added the recommended packages: ghostscript, aspell, libiconv, netpbm and imagemagick.

After

./configure --with-guile2 --enable-guile2
make

I got a texmacs bin which caused a segmentation fault whenever I tried any session.

Thanks to the file provided by Joyez, I found that optimization options were different and, unsurprisingly, stronger in the version which caused the segmentation fault.

Modification:

1) I edited the file src/makefile and removed two mentions of "-fno-rtti" in that file.

2) make clean

3) make
---
The following plugins (sessions) : maxima, gnuplot, python, scheme, shell, lisp (clisp) seem to work with the new texmacs bin.

I have also tried, in a text document, an obvious typo and "Edit->Ortography" has shown the right version which I selected and it replaced the typo.

Juan Hierro <buscaideas>
Mon 07 Aug 2023 04:10:51 PM UTC, comment #12: 

For reference, there is also a duplicate bug #61163.

Joris van der Hoeven <vdhoeven>
Group administrator
Sun 02 Apr 2023 11:12:33 AM UTC, comment #11: 

I attach a file for comparing how QTMPipeLink.cpp is built with autotools (bugged) and cmake (no bug). To me, nothing obvious pops out...

(file #54548)

Philippe Joyez <pjoyez>
Group Member
Thu 10 Nov 2022 06:22:08 PM UTC, comment #10: 

Yes, see my comment #5: most likely it affects only Qt 5.15.x, not before, nor after. Alas, most linux distros currently use this last Qt 5 version.

Also Jeroen's finding is really strange since it points to a build configuration issue, but this is black magic for me.

Philippe Joyez <pjoyez>
Group Member
Sun 06 Nov 2022 09:50:17 PM UTC, comment #9: 

Could you please investigate with which versions of Qt you have this problem.

I tried with Qt 5.9.9 and did not experience any problems.
Did something change inside Qt?

Joris van der Hoeven <vdhoeven>
Group administrator
Fri 29 Jul 2022 11:44:50 AM UTC, comment #8: 

I can successfully compile and use plugins when compiling with cmake (on Fedora with Qt 5.15.5 and on Debian with Qt 5.15.2). I only get this segfault when using autotools (configure).

Jeroen Wouters <jeronim>
Group Member
Sun 12 Dec 2021 03:24:45 PM UTC, comment #7: 

The proposed fix is to modify the configure script so that it disables qtpipes when Qt version is 5.15. However, I'm not skilled enough with m4 to propose a patch.

I changed again the summary to make clear it's not only a spellchecker issue

Philippe Joyez <pjoyez>
Group Member
Thu 16 Sep 2021 07:10:26 AM UTC, comment #6: 

Unsurprisingly, this bug also affects interactive sessions (bug 61163).

Philippe Joyez <pjoyez>
Group Member
Tue 27 Jul 2021 11:50:58 AM UTC, comment #5: 

In Suse's Open Build Service I have build AppImages based on Leap 42.3 (Qt 5.6) and Leap 15.2 (Qt 5.12) and in both, spell checking works fine (even without #3 patch).

Actually, ahead of qt6 release, there was a change in qprocess_unix.cpp in the area where the issue occurs and which refers to QTBUG-86285  (https://github.com/qt/qtbase/commit/2ed99ff5ca338ac02f71c347b1449d4662e6c221). And the lines that are changed in that commit had been introduced in Qt 5.15. So it's likely only Qt 5.15 that has an issue, and for which we need a workaround.

I change the summary from "spell check trigger segmentation fault error for ubuntu .deb version" to "spell check trigger segmentation fault error with Qt 5.15.x"

Philippe Joyez <pjoyez>
Group Member
Sun 25 Jul 2021 04:34:55 PM UTC, comment #4: 

A possible workaround for the Qt5 issue is to disable qt pipes (e.g. configure with --disable-qtpipes)

This requires to adjust in socket_notifier.cpp :

#ifndef QTTEXMACS  ->  #if !(defined (QTTEXMACS) && defined (QTPIPES))
 

Tested to give functional spellcheck.

Philippe Joyez <pjoyez>
Group Member
Sun 25 Jul 2021 02:39:02 PM UTC, comment #3: 

I could make the qt6 version to spellcheck correctly with the following patch:

--- /A/QTMPipeLink.cpp
+++ /B/QTMPipeLink.cpp
@@ -49,7 +49,14 @@
 QTMPipeLink::launchCmd () {
   if (state () != QProcess::NotRunning) killProcess (1000);
   FIXME: is UTF8 the right encoding here?
+#if (QT_VERSION >= QT_VERSION_CHECK(5,1,0))
+  QStringList tokens = QProcess::splitCommand(utf8_to_qstring(cmd));
+  QProcess::setProgram(tokens.takeFirst());
+  QProcess::setArguments(tokens);
+  QProcess::start();
+#else
   QProcess::start(utf8_to_qstring(cmd));
+#endif
   bool r= waitForStarted ();
   if (r) {
     connect (this, SIGNAL(readyReadStandardOutput ()), SLOT(readErrOut ()));

However, with this patch the qt5 version still segfaults in Qt, just as in the previous comment. After installing libqt5core5a-dbgsym, gdb says the segfault is at line 461 of https://github.com/qt/qtbase/blob/5.15.2/src/corelib/io/qprocess_unix.cpp (I'm using the current Qt 5.15.2+dfsg-9 official Debian Bullseye build; there is no debian patch on this file) which, surprisingly, is an innoccuous assignment. Nevertheless, when setting up a break point close to the segfault, the program  seemingly execs line 462 before 461 (see below)! I do not understand what is wrong nor why gdb gives weird inconsistent info, but most likely the crash is not really occuring at line 461. In any case I presently do not see what to do to solve the issue. Since it works fine in qt6, it could be a qt5 bug for which we would have to find a workaround...

Below I had set the break point at line 461 (I'm sure of that) and gdb first stops saying the break point is at 462. Then, when you step with "n" it says a segfault occurs at line 461...

Thread 1 "texmacs.bin" hit Breakpoint 1, QProcessPrivate::startProcess (
    this=0x5555566c7240) at io/qprocess_unix.cpp:462
462     if (typeid(*q) != typeid(QProcess))
(gdb) n
[Thread 0x7fffe97fa700 (LWP 56860) exited]
[Thread 0x7fffeaffd700 (LWP 56862) exited]
[Thread 0x7fffea7fc700 (LWP 56861) exited]
[Thread 0x7fffe9ffb700 (LWP 56859) exited]
139     { return !operator==(__arg); }
(gdb) n

Thread 1 "texmacs.bin" received signal SIGSEGV, Segmentation fault.
0x00007ffff6ec977e in QProcessPrivate::startProcess (this=0x5555566c7240)
    at io/qprocess_unix.cpp:461
461     int ffdflags = FFD_CLOEXEC;

Philippe Joyez <pjoyez>
Group Member
Thu 22 Jul 2021 09:25:16 AM UTC, comment #2: 

By comparing
https://doc.qt.io/archives/qt-4.8/qprocess.html#start
https://doc.qt.io/qt-5/qprocess.html#start

the problem seems that qt5 no longer accepts a single string  containing the program and its arguments in start().

Philippe Joyez <pjoyez>
Group Member
Thu 22 Jul 2021 09:00:07 AM UTC, comment #1: 

I confirm the issue. There seems to be a problem with Qt pipes when using Qt>=5 (which the xUbuntu_20.04 package uses). I believe the static package still uses Qt4.

With a Qt5 build, on Debian 11:

TeXmacs] debug-shell, Launching 'hunspell -a -i utf-8 -d en_US'

Thread 1 "texmacs.bin" received signal SIGSEGV, Segmentation fault.
0x00007ffff6ec977e in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
(gdb) bt
#0  0x00007ffff6ec977e in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#1  0x00007ffff6ec4aa3 in QProcess::start(QString const&, QFlags<QIODevice::OpenModeFlag>) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#2  0x000055555571ed6b in QTMPipeLink::launchCmd() (this=0x55555a0a11c0) at ./Plugins/Qt/QTMPipeLink.cpp:52
#3  0x0000555555f0ce58 in qt_pipe_link_rep::start() (this=0x55555a0a11a0) at ./Plugins/Qt/qt_pipe_link.cpp:74
#4  0x0000555555ce2efa in ispeller_rep::connect_spellchecker(string) (this=0x55555a50b040, cmd=...)
    at ./Plugins/Ispell/ispell.cpp:144


It's broken too with a Qt6 build, but not as badly:

(ran with --debug-io)
TeXmacs] debug-spell, Start english
TeXmacs] debug-shell, Launching 'hunspell -a -i utf-8 -d en_US'
TeXmacs] debug-shell, TeXmacs] Error: cannot start 'hunspell -a -i utf-8 -d en_US'
TeXmacs] debug-spell, Received Error: cannot start application
TeXmacs] debug-shell, Launching 'aspell -a --encoding=utf-8 --language-tag=en_US'
TeXmacs] debug-shell, TeXmacs] Error: cannot start 'aspell -a --encoding=utf-8 --language-tag=en_US'
TeXmacs] debug-spell, Received Error: cannot start application
TeXmacs] std-error, Error: no dictionary installed for english (en_US)
TeXmacs] std-error, The corresponding text is not checked
TeXmacs] debug-spell, End english

Both hunspell and aspell are installed on my system and there is no error when launching "hunspell -a -i utf-8 -d en_US" or "aspell -a --encoding=utf-8 --language-tag=en_US" in a console (they wait for input).

Philippe Joyez <pjoyez>
Group Member
Sat 17 Jul 2021 04:50:17 PM UTC, original submission:  

Hi,

I installed texmacs from [here](https://www.texmacs.org/tmweb/download/linux-packages.en.html#ubuntu), and use *TeXmacs package for xUbuntu_20.04 with a 64 bits Intel/AMD processor*

But if I try to spell check the document, will trigger below error and spell check not work.

I have installed aspell and it works correctly.

I re-installed the static binary version and it works fine. So it seems there is bug for the ubuntu .deb version.

```
TeXmacs] With linked TrueType support
TeXmacs] debug-shell, Launching 'aspell -a --encoding=utf-8 --language-tag=en_US'
Throwing segmentation fault
-------------------------------------------------
Error message:
  segmentation fault

System information:
  TeXmacs version  : 2.1
  Built by         : abuild
  Building date    : Tue Jun 22 11:58:17 UTC 2021
  Operating system : linux-gnu
  Vendor           : pc
  Processor        : @CONFIG_HOST_CPU@
  Crash date       : 2021年 07月 17日 星期六 23:35:15 CST

Editor status:
  Root path          : [ 0 ]
  Current path       : [ 0, 0, 3, 1 ]
  Shifted path       : [ 0, 0, 3, 1 ]
  Physical selection : [ 0, 0, 3, 1 ] -- [ 0, 0, 3, 1 ]

Backtrace of C++ stack:
  texmacs.bin : () + 0xed5206
  texmacs.bin : () + 0x420100
  /usr/lib/x86_64-linux-gnu/libc.so.6 : () + 0x41040
  /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 : () + 0x22d3ce
  /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 : QProcess::start(QString const&, QFlags<QIODevice::OpenModeFlag>) + 0xd7
  texmacs.bin : () + 0x31967c
  texmacs.bin : () + 0xd7664d
  texmacs.bin : () + 0xa8c444
  texmacs.bin : () + 0xa8d8f5
  texmacs.bin : () + 0xa8f3be
  texmacs.bin : () + 0xa95b29
  texmacs.bin : () + 0xa96294
  texmacs.bin : () + 0xa97866
  texmacs.bin : () + 0xf6df7a
  texmacs.bin : () + 0xf6f3ef
  texmacs.bin : () + 0xf723b5
  texmacs.bin : () + 0xf71f1a
  texmacs.bin : () + 0xf73fc9
  texmacs.bin : () + 0xf744ac
  texmacs.bin : () + 0x9e00f4
  texmacs.bin : () + 0x10967a0
  texmacs.bin : () + 0x1099882
  texmacs.bin : () + 0x1098e9d
  texmacs.bin : () + 0x1096c82
  texmacs.bin : () + 0x10ee27c
  texmacs.bin : () + 0x10edeb0
  texmacs.bin : () + 0x10ee152
  texmacs.bin : () + 0xa3a1bd
  texmacs.bin : () + 0xc08b94
  texmacs.bin : () + 0x6c2211
  texmacs.bin : () + 0x6c515c
  texmacs.bin : () + 0x99d8cf
  texmacs.bin : () + 0x109994f
  texmacs.bin : () + 0x1098a0e
  texmacs.bin : () + 0x1096c82
  texmacs.bin : () + 0x10ee27c
  texmacs.bin : () + 0x10edeb0
  texmacs.bin : () + 0x10ee152
  texmacs.bin : () + 0xa3a2be
  texmacs.bin : () + 0xc04d5f
  texmacs.bin : () + 0x6c7eea
  texmacs.bin : () + 0xd63f36
  texmacs.bin : () + 0xd645aa
  texmacs.bin : () + 0x30b6a4
  texmacs.bin : () + 0xba5de8
  /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 : () + 0x2eeb44
  /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 : QTimer::timeout(QTimer::QPrivateSignal) + 0x3e
  /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 : QObject::event(QEvent*) + 0x1cf
  /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 : QApplicationPrivate::notify_helper(QObject*, QEvent*) + 0x83
  texmacs.bin : () + 0xba5500
  /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 : QCoreApplication::notifyInternal2(QObject*, QEvent*) + 0x12a
  /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 : QTimerInfoList::activateTimers() + 0x3e3
  /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 : () + 0x3101bc
  /lib/x86_64-linux-gnu/libglib-2.0.so.0 : g_main_context_dispatch() + 0x25b
  /lib/x86_64-linux-gnu/libglib-2.0.so.0 : () + 0xa8c68
  /lib/x86_64-linux-gnu/libglib-2.0.so.0 : g_main_context_iteration() + 0x33
  /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 : QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 0x64
  /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 : QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 0x12b
  /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 : QCoreApplication::exec() + 0x94
  texmacs.bin : () + 0x2868f5
  texmacs.bin : () + 0x10afb73
  texmacs.bin : () + 0x11067fe
  texmacs.bin : () + 0x10edeb0
  texmacs.bin : () + 0x1106e17
  texmacs.bin : () + 0x1106f04
  texmacs.bin : () + 0x10ec16a
  texmacs.bin : () + 0x10afcfb
  texmacs.bin : () + 0x25f0a6
  /usr/lib/x86_64-linux-gnu/libc.so.6 : __libc_start_main() + 0xd5
  texmacs.bin : () + 0x284ece

-------------------------------------------------
TeXmacs] failed-error, Exception, segmentation fault
```

zongtao wang <wztdream>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #54548:  bug60931.txt added by pjoyez (14KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by buscaideas (Posted a comment)
  • -email is unavailable- added by jeronim (Posted a comment)
  • -email is unavailable- added by vdhoeven (Updated the item)
  • -email is unavailable- added by pjoyez (Posted a comment)
  • -email is unavailable- added by wztdream (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-09-03 pjoyez StatusNeed Info Fixed
        Open/ClosedOpen Closed
    2023-04-02 pjoyez Attached File- Added bug60931.txt, #54548
    2022-11-06 vdhoeven Priority7 - High 9 - Immediate
        Assigned toNone vdhoeven
    2022-11-06 vdhoeven Priority5 - Normal 7 - High
        StatusConfirmed Need Info
        Assigned to_86389 None
    2021-12-12 pjoyez Summaryspell check trigger segmentation fault error with Qt 5.15.x qtpipe issue with Qt 5.15.x -> external plugins cause segfault
    2021-11-10 vdhoeven Assigned toNone _86389
    2021-07-27 pjoyez Summaryspell check trigger segmentation fault error for ubuntu .deb version spell check trigger segmentation fault error with Qt 5.15.x
    2021-07-22 pjoyez StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code