bugGNU Octave - Bugs: bug #58678, Deadlock when deleting a figure...

 
 

bug #58678: Deadlock when deleting a figure while another figure is beingdeleted

Submitted by:  Pantxo Diribarne <pantxo>
Submitted on:  Mon 29 Jun 2020 08:27:19 PM UTC  
 
Category:  Plotting with OpenGL Severity:  4 - Important
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  dev 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.

 

Mon 29 Jun 2020 08:27:19 PM UTC, original submission:  

Here is a robust way to deadlock with Octave 5.1, stable and default:

hf = figure ();
hf2 = figure ();
addlistener (hf, "beingdeleted", @() delete (hf2));
delete (hf);

I dug into this and it turns out that this sequence provokes a recursive call to F__go_delete__. This function uses an octave::autolock to lock the graphics mutex and then unlock it at return. When graphics_toolkit::finalize is called, the graphics mutex has been locked twice and using gh_manager::unlock is not enough to unlock it (unlocking twice avoids the deadlock).

IOW, I just discovered that octave_mutex is a recursive mutex, and there is no way to unlock it unless you know the number of times it has been previously locked in the same thread. See also [1] for a discussion about recursive mutexes.

So both qt_graphics_toolkit::initialize and finalize, can possibly deadlock.

PS: Contrary to what I have said in [2], our implementation of mutex is thus very well suited for recursive use with octave::autolock.

PPS: I tagged this bug as segfault since a deadlock looks as critical.

[1] http://www.zaval.org/resources/library/butenhof1.html
[2] https://octave.1599824.n4.nabble.com/segfaults-in-graphics-code-likely-threading-issues-td4697518.html

Pantxo Diribarne <pantxo>
Project Member

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (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.

     

     

     

    No changes have been made to this item

    Back to the top


    Powered by Savane 3.5