octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #42176] Octave built without OpenMP crashes wh


From: Mike Miller
Subject: [Octave-bug-tracker] [bug #42176] Octave built without OpenMP crashes when unloading OpenMP-enabled oct-files
Date: Wed, 23 Apr 2014 12:15:05 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36

URL:
  <http://savannah.gnu.org/bugs/?42176>

                 Summary: Octave built without OpenMP crashes when unloading
OpenMP-enabled oct-files
                 Project: GNU Octave
            Submitted by: mtmiller
            Submitted on: Wed 23 Apr 2014 08:15:04 AM EDT
                Category: Configuration and Build System
                Severity: 2 - Minor
                Priority: 5 - Normal
              Item Group: Crash
                  Status: None
             Assigned to: mtmiller
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: GNU/Linux

    _______________________________________________________

Details:

When Octave unloads an oct-file that uses OpenMP, either directly or
indirectly via a third-party library, Octave can crash, either immediately or
after receiving a signal of some kind, such as a SIGCHLD or SIGCONT. The cause
of the crash appears seems to be because OpenMP creates a thread pool that
runs in the background until the process exits. When the OpenMP library is
unloaded from the process, one of the OpenMP threads will segfault when
scheduled to run.

This is not just a problem with some theoretical oct-files that users may
create with OpenMP. The GraphicsMagick library uses OpenMP, and the
__magick_read__ oct-file that acts as the interface to the library for Octave
image functions suffers from this problem right now.

Example:


octave:1> im = imread ("large_file.tif");
warning: your version of GraphicsMagick limits images to 8 bits per pixel
octave:2> clear -f
octave:3> system ("pwd");
/home/mike
panic: Segmentation fault -- stopping myself...
attempting to save variables to 'octave-workspace'...
save to 'octave-workspace' complete
octave:4> Segmentation fault


The same occurs for me when backgrounding Octave with Ctrl-Z and resuming
after the clear -f. When running Octave in gdb, the segfault happens
immediately after the clear -f.

If OMP_NUM_THREADS is set to 1, no segfault occurs because OpenMP does not
create any additional threads.

If Octave is compiled without OpenMP itself, then it has no reason to keep the
OpenMP library (libgomp in the case of gcc) in process memory, so it is
unloaded when the oct-file that loaded it is removed. If Octave is built with
-fopenmp, then all Octave libraries and executables will keep the libgomp
library in memory for the entire execution lifetime, so unloading an oct-file
will not unload libgomp.

If there are any other suggestions for how to solve the problem of unloading
an oct-file that may have done some OpenMP work without unloading libgomp from
the process, please comment here. The only reasonable solutions I've seen when
researching this are to either use LD_PRELOAD when the program is started, or
to build the entire program with -fopenmp. If I don't hear any better
solutions or strong arguments not to do it, I will work on a change to enable
OpenMP in Octave by default from now on.




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?42176>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]