retext-project / retext

ReText: Simple but powerful editor for Markdown and reStructuredText
GNU General Public License v2.0
1.88k stars 196 forks source link

ReText crash upon search #586

Closed szpeter80 closed 2 years ago

szpeter80 commented 2 years ago

Installed from Ubuntu ("Ubuntu 22.04 LTS") official repo, package is retext/jammy,jammy,now 7.2.3-1 all [installed], python is Python 3.10.4

Searching for '???' in the markdown pane, makes the program to crash. It is repeatable, happens all the time. The source do contain the term '???', it does not affect (no crash, no glitch observed) rendering of the preview or html.

Is something broken in my system or it is a ReText bug?

The error message is the following:

pete@szpl-legion:$ retext Using configuration file: /home/pete/.config/ReText project/ReText.conf Process Process-2: Process Process-5: Process Process-3: Process Process-4: Process Process-1: Traceback (most recent call last): Traceback (most recent call last): File "/usr/lib/python3.10/multiprocessing/process.py", line 315, in _bootstrap self.run() Traceback (most recent call last): Traceback (most recent call last): File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run self._target(*self._args, self._kwargs) Traceback (most recent call last): File "/usr/lib/python3.10/multiprocessing/process.py", line 315, in _bootstrap self.run() File "/usr/share/retext/ReText/converterprocess.py", line 72, in _converter_process_func job = receiveObject(conn_child) File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run self._target(*self._args, *self._kwargs) File "/usr/share/retext/ReText/converterprocess.py", line 41, in receiveObject sizeBuf = recvall(sock, 4) File "/usr/share/retext/ReText/converterprocess.py", line 72, in _converter_process_func job = receiveObject(conn_child) File "/usr/share/retext/ReText/converterprocess.py", line 41, in receiveObject sizeBuf = recvall(sock, 4) File "/usr/share/retext/ReText/converterprocess.py", line 34, in recvall raise EOFError('Received 0 bytes from socket while more bytes were expected. Did the sender process exit unexpectedly?') File "/usr/share/retext/ReText/converterprocess.py", line 34, in recvall raise EOFError('Received 0 bytes from socket while more bytes were expected. Did the sender process exit unexpectedly?') File "/usr/lib/python3.10/multiprocessing/process.py", line 315, in _bootstrap self.run() File "/usr/lib/python3.10/multiprocessing/process.py", line 315, in _bootstrap self.run() File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run self._target(self._args, self._kwargs) EOFError: Received 0 bytes from socket while more bytes were expected. Did the sender process exit unexpectedly? EOFError: Received 0 bytes from socket while more bytes were expected. Did the sender process exit unexpectedly? File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run self._target(*self._args, *self._kwargs) File "/usr/share/retext/ReText/converterprocess.py", line 72, in _converter_process_func job = receiveObject(conn_child) File "/usr/share/retext/ReText/converterprocess.py", line 72, in _converter_process_func job = receiveObject(conn_child) File "/usr/share/retext/ReText/converterprocess.py", line 41, in receiveObject sizeBuf = recvall(sock, 4) File "/usr/lib/python3.10/multiprocessing/process.py", line 315, in _bootstrap self.run() File "/usr/share/retext/ReText/converterprocess.py", line 41, in receiveObject sizeBuf = recvall(sock, 4) File "/usr/share/retext/ReText/converterprocess.py", line 34, in recvall raise EOFError('Received 0 bytes from socket while more bytes were expected. Did the sender process exit unexpectedly?') File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run self._target(self._args, **self._kwargs) File "/usr/share/retext/ReText/converterprocess.py", line 34, in recvall raise EOFError('Received 0 bytes from socket while more bytes were expected. Did the sender process exit unexpectedly?') File "/usr/share/retext/ReText/converterprocess.py", line 72, in _converter_process_func job = receiveObject(conn_child) EOFError: Received 0 bytes from socket while more bytes were expected. Did the sender process exit unexpectedly? File "/usr/share/retext/ReText/converterprocess.py", line 41, in receiveObject sizeBuf = recvall(sock, 4) EOFError: Received 0 bytes from socket while more bytes were expected. Did the sender process exit unexpectedly? File "/usr/share/retext/ReText/converterprocess.py", line 34, in recvall raise EOFError('Received 0 bytes from socket while more bytes were expected. Did the sender process exit unexpectedly?') EOFError: Received 0 bytes from socket while more bytes were expected. Did the sender process exit unexpectedly? Segmentation fault (core dumped) pete@szpl-legion:~$

szpeter80 commented 2 years ago

Tried in a new directory with venv, the crash does not happen. But Webkit renderer is not available (greyed out), and that is much needed for complex CSS styled HTML output, which cannot be rendered (colors / fonts gone, some borders are rendered incorrectly etc) by the default renderer.

mitya57 commented 2 years ago

Hi!

I just checked on Ubuntu 22.04 installation and ReText from official repos, and I cannot reproduce this. Does it happen with any file or only with some specific one? Does it matter with any search term, or it happens only with ????

Can you help me debug this by running python3 /usr/bin/retext in gdb and obtaining a stack trace? I will give you more details if you can.

Tried in a new directory with venv, the crash does not happen. But Webkit renderer is not available (greyed out)

Run pip install PyQtWebEngine, it will make a similar Qt WebEngine renderer available.

szpeter80 commented 2 years ago

Sorry for late reply, it was a busy few days...

Updated the venv to latest packages and installed the PyQtWebEngine package - live preview now selectable but the output is blank white.

Did some experiments to help it narrow down:

I can try the gdb method, can you give some pointers how to properly do that?

mitya57 commented 2 years ago

Updated the venv to latest packages and installed the PyQtWebEngine package - live preview now selectable but the output is blank white.

Please check for errors in terminal. If it says that it can't find QtWebEngineProcess, then setting QTWEBENGINEPROCESS_PATH may help. But then it's a bug in PyQt, not ReText.

the crash happens at a specific part of the document

Does it still happen if you remove everything except that part? Can you share that part with me? Please attach it here or send it to mitya57@gmail.com.

I can try the gdb method, can you give some pointers how to properly do that?

If you can share the document then maybe I will reproduce it itself and debugging it on your side won't be needed. Anyway, here is an instruction:

  1. Enable debug symbols repository as described here: https://wiki.ubuntu.com/DebuggingProgramCrash#Non-built-in_debug_symbol_packages_.28.2A-dbgsym.29.
  2. Install some packages: sudo apt install python3-dbg libqt5core5a-dbgsym libqt5gui5-dbgsym libqt5widgets5-dbgsym libqt5webkit5-dbgsym python3-pyqt5-dbgsym.
  3. Run gdb python3.
  4. In gdb shell, enter run /usr/bin/retext.
  5. Reproduce the bug and make it crash.
  6. Enter bt (same as backtrace).
  7. Paste or attach output here.
szpeter80 commented 2 years ago

The document contains a lot of personal and sensitive data, i tried to make an anonimized version, but changing it makes the crash disappear. I noticed that the crash happens if i freshly open Retext, and the search for ?? is the first action. If i mess around (scroll, switch to other tab, edit etc), the crash is not happening with the same document.

I did the backtrace, hope it helps.

20220616_retext_backtrace.txt

I dont know if it matters, but the document has embedded CSS

mitya57 commented 2 years ago

It is helpful, thank you very much! I will look in the next few days.

mitya57 commented 2 years ago

Sorry for the delay in reply. I looked at this a couple of weeks ago, but did not figure out much. Today I looked again, and now I at least understand what the Qt code that crashes is supposed to do.

My hypothesis is that it's related to highlighting of current line. And I have a few more questions.

I don't want to take much of your time, but if you have some time, maybe you can also try the version from master branch? It was ported to Qt 6, so it would be nice to know if this bug is fixed in Qt 6.

Here is how you can test it on Ubuntu:

szpeter80 commented 2 years ago

I have just tested with master, and i am not able to trigger the problem anymore. As a check, it still trigger with the version installed from packages, so the still document has the cause.

As this bug is a very edge case and not present in the current master, i propose to close this with something like "fixed upstream" or so. And thanks for your efforts!

mitya57 commented 2 years ago

Ok, thank you again! I will try to make a new release soon.