bugGNU Octave - Bugs: bug #55736, Segfault when copying source file...


bug #55736: Segfault when copying source file text to clipboard in octave-gui

Submitted by:  None
Submitted on:  Mon 18 Feb 2019 03:57:27 AM UTC  
Category:  GUI Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  None
Originator Name:  jwoithe Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  5.1.0
Operating System:  GNU/Linux

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Tue 26 Feb 2019 02:28:23 AM UTC, comment #17: 

No problem, thanks for clarifying.

As per comment #14, my testing indicates that the patches have addressed the bug, so from where I stand it seems that the bug is now fixed.

Tue 26 Feb 2019 02:06:22 AM UTC, comment #16: 

This bug is already marked "ready for test", meaning that the fixes have already been applied and are just waiting for confirmation to mark it fixed.

Mike Miller <mtmiller>
Project Administrator
Tue 26 Feb 2019 01:39:12 AM UTC, comment #15: 

Does the change in this bug's release from 5.0.91 (where I observed the issue) to 5.1.0 indicate that the fixes mentioned in comment #14 will not make it into version 5.1.0 when it is released?  The changesets looked to be against the stable branch, which I thought was the branch to be used for the upcoming stable version.

Thu 21 Feb 2019 05:42:13 AM UTC, comment #14: 

Based on the result of the test I reported in comment #12, applying Changesets 26746:3d0f687e4a21 and 26755:c39d26971f4b will prevent the segfault. Thanks for the fix.

Thu 21 Feb 2019 05:14:47 AM UTC, comment #13: 

I pushed my additional changes here:


John W. Eaton <jwe>
Project Administrator
Wed 20 Feb 2019 10:29:02 PM UTC, comment #12: 

With the patch from comment 8 still in place, I applied the additional one posted with comment 11.  This was to Octave 5.0.91-7b9a5ab8350f, compiled against qt4.  Running "octave --gui" resulted in the Octave GUI starting normally.  Doing an "Edit-Copy" from a source file (or using its Ctrl-C shortcut) did NOT crash the GUI as it has in the past.  The text was copied to the clipboard and a subsequent paste operation had the expected result.

Based in this, it seems that 3d0f687e4a21 combined with the additional patch from comment 11 (file #46314) are sufficient to prevent the segfault when doing an "Edit-Copy" action from a source file in an editor widget.

Wed 20 Feb 2019 02:09:25 PM UTC, comment #11: 

Torsten:  If you make this change, then you should see the crash when constructing the documentation object:

diff --git a/libgui/src/documentation.cc b/libgui/src/documentation.cc
--- a/libgui/src/documentation.cc
+++ b/libgui/src/documentation.cc
@@ -104,7 +104,7 @@ namespace octave
     connect(m_help_engine, SIGNAL(setupFinished()),
             m_help_engine->searchEngine(), SLOT(indexDocumentation()));

-    if (! m_help_engine->setupData())
+    //    if (! m_help_engine->setupData())
         QMessageBox::warning (this, tr ("Octave Documentation"),

I've attached an additional patch that I think protects all uses of m_help_engine.  There is probably a better way to do this job, but for now it would be great if we could just avoid the crash.

It would probably be good to insert a message in the documentation pane itself that explains possible reasons that the re is no text, but that could wait until later.

(file #46314)

John W. Eaton <jwe>
Project Administrator
Wed 20 Feb 2019 05:48:58 AM UTC, comment #10: 

I wasn't able to reproduce the issue and are now making a completely new build without docs.

As done in other methods of the documentation class I suggest to test m_help_engine for null pointer in cpoyClipboard before accessing m_doc_browser.

Torsten Lilge <ttl>
Project Member
Tue 19 Feb 2019 10:44:54 PM UTC, comment #9: 

I applied 3d0f687e4a21 to Octave 5.0.91-7b9a5ab8350f, compiled against qt4.  Running "octave --gui" crashes immediately with a segfault in QHelpEngine::contentWidget(), called from documentation::documentation() in documentation.cc, line 178.
This line delimits m_help_engine, and m_help_engine is NULL: thus the segfault.  This is unsurprising since the applied patch sets m_help_engine to NULL in the case where setupData() fails.

Since m_help_engine is used to create a number of other objects (content for example) which are then also dereferenced in the lines following 178, it's clear that a fix for this is not as simple as the addition of a single NULL test on m_help_engine at line 178.

Tue 19 Feb 2019 09:35:24 PM UTC, comment #8: 

It looks to me like the problem doesn't depend on whether docs are enabled, but instead whether the call to m_help_engine->setupData () succeeds in the constructor for the documentation class.  If it fails, then the constructor returns early and the doc browser is not fully constructed.  If docs are disabled, there is no warning about that either.

I pushed the following changeset that seems to avoid the crash if the help engine setup fails:


John W. Eaton <jwe>
Project Administrator
Tue 19 Feb 2019 06:15:59 PM UTC, comment #7: 

Indeed, I haven't noticed the --disable-docs option and that might be reason for the crash. I am going to prepare a patch.

Torsten Lilge <ttl>
Project Member
Tue 19 Feb 2019 12:11:08 PM UTC, comment #6: 

Correct: documentation generation was disabled because the system in question did not have TeX installed.  The user didn't need the documentation as they are already familiar with web-based resources, so this didn't seem to be a major issue.

My understanding from comment 5 is that a consequence of "--disable-docs" is that there is nothing for the documentation browser to display.  Could the lack of documentation give rise to the NULL pointer which then trips up the "Edit-Copy" action?

Tue 19 Feb 2019 10:37:23 AM UTC, comment #5: 

It is not clear to me that everybody noted that Octave was configured with "--disable-docs"option (see verbatim section in the original submission), hence the empty doc browser.

Pantxo Diribarne <pantxo>
Project Member
Tue 19 Feb 2019 06:19:35 AM UTC, comment #4: 

The documentation browser is completely empty when it is visible.

Tue 19 Feb 2019 06:05:48 AM UTC, comment #3: 

From original submission:

The segfault occurs regardless of whether the documentation pane is visible or not

When the documentation pane is visible, does the documentation browser show any contents? I am wondering how the documentation browser can be functional when m_doc_browser is the null pointer.

Torsten Lilge <ttl>
Project Member
Mon 18 Feb 2019 11:25:29 PM UTC, comment #2: 

I recompiled Octave 5.0.91-7b9a5ab8350f in a fresh tree against the most recent version of qt5 easily available for the distribution (qt5 5.9.6).  QScintilla was version 2.11.1 (the latest available) compiled against qt5 5.9.6.  Highlighting text in the source editor and hitting Ctrl-C still crashed octave with a segfault.  The location of the segfault was the same.  The m_doc_browser pointer was 0x0 (NULL) in this case.

I will attach the gdb stack trace in case it is instructive.

(file #46305)

Mon 18 Feb 2019 08:01:52 PM UTC, comment #1: 

Can you try building Octave with Qt 5? I can't reproduce this with Qt 5.11.3 on Debian. Octave does still build with Qt 4.8, but a recent supported version of Qt 5 is recommended.

Mike Miller <mtmiller>
Project Administrator
Mon 18 Feb 2019 03:57:27 AM UTC, original submission:  

System: Slackware64 14.2

Attempting to copy text from a source file to the clipboard in octave-gui from Octave 5.0.91-7b9a5ab8350f reliably triggers a segfault.  The method used to do the copy is irrelevant: both the Edit-Copy menu item and the Ctrl-C keyboard shortcut cause the problem.

The core dump file indicates that the crash occurs in documentation::copyClipboard().  Inspection shows that m_doc_browser is not a valid pointer (0x7fffffff00000000), and it is the dereferencing of this pointer as part of the call to m_doc_browser->hasFocus() which triggers the segfault.

The segfault occurs regardless of whether the documentation pane is visible or not.

Commenting out the four code lines in documentation::copyClipboard() is sufficient to stop the segfault from happening.  With this change, text is copied from source files to the clipboard.  Clearly this is only a temporary workaround though; I guess the change would make it impossible to copy from the documentation pane if that was ever attempted.

Octave 4.4.1 on the same system does not exhibit the problem.

Slackware64 14.2 has Qt 4.8.7 and it is against this that octave has been compiled.  Octave was configured using

../configure --with-blas=openblas --libdir=/usr/local/lib64 --disable-docs

Omitting "--with-blas-openblas", causing octave to use ATLAS instead, makes no difference.

Please let me know if I can be of further assistance.



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

Attach Files:

Attached Files
file #46314:  doc-diffs.txt added by jwe (9KiB - text/plain)
file #46305:  octave_segfault_gdb_output.txt added by None (4KiB - text/plain - Stack trace from gdb with octave compiled against qt5)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by ttl (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-02-26 mtmiller StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
    2019-02-26 mtmiller Release5.0.91 => 5.1.0
    2019-02-20 jwe Attached File- => Added doc-diffs.txt, #46314
    2019-02-19 jwe StatusNeed Info => Ready For Test
    2019-02-18 None Attached File- => Added octave_segfault_gdb_output.txt, #46305
    2019-02-18 mtmiller StatusNone => Need Info

    Back to the top

    Powered by Savane 3.5