Bug report #13196

getSagaInstalledVersion() interrupted system call on OS X

Added by William Kyngesburye over 8 years ago. Updated almost 8 years ago.

Status:Closed
Priority:High
Assignee:Victor Olaya
Category:Processing/SAGA
Affected QGIS version:2.8.3 Regression?:No
Operating System:OS X Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:21257

Description

This appeared recently, when QGIS starts and the Processing plugin initializes and tries to get the saga version, I get an interrupted system call error at the proc.readlines step. Not much help online about this other than "devs should handle interrupts", so I've been commenting out the test and forcing it to the version I bundle in the Mac app.

I figured out a solution: add bufsize=1 to the subprocess.popen() options. This works for OS X, but I suppose it should be tested on Linux and Windows before applying it. The simplest fix is to apply it for all systems, but it may need a Mac-only insertion of the option (messy) if it breaks on other systems.

Applies to both LTR 2.8 and master.

History

#1 Updated by William Kyngesburye over 8 years ago

P.S.: it may be a good idea to apply this to other places that read lines from subprocess output (saga and other providers). I think I've seen random interrupted system calls at other times, but I'm not sure.

#2 Updated by William Kyngesburye over 8 years ago

Argh! Now it's more complicated - it seems that it's not the bufsize that's fixing it, but python compilation, it's broken again. If I change it back to the original code, delete the SagaUtils.pyc file, it runs fine. But if I then start QGIS again, it runs from the now-compiled SagaUtils.pyc file and I get the interrupted system call error. Maybe a buggy bytecode compiler on OS X or this python version (2.7.2).

.pyo doesn't help - if I delete the .pyc, compile to .pyo manually, and start QGIS, it still generate the .pyc (QGIS is probably not running python in optimize mode) AND immediately gives the interrupted system call error.

None of the methods to disable bytecode generation work, maybe it's a Mac thing or because the python interpreter is embedded in QGIS.

And even when trying alternate bytecode .pyo and disabling options, there were random interrupted system calls when the compiled files were not present, with and without the bufsize option. Grr. And I've had 2 different traces with the error (though it always comes down to the proc.readlines() line):

Traceback (most recent call last):
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 228, in startPlugin
    plugins[packageName].initGui()
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/ProcessingPlugin.py", line 57, in initGui
    Processing.initialize()
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/core/Processing.py", line 150, in initialize
    Processing.loadFromProviders()
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/core/Processing.py", line 166, in loadFromProviders
    Processing.loadAlgorithms()
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/core/Processing.py", line 201, in loadAlgorithms
    Processing.updateProviders()
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/core/Processing.py", line 174, in updateProviders
    provider.loadAlgorithms()
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/core/AlgorithmProvider.py", line 57, in loadAlgorithms
    self._loadAlgorithms()
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/algs/saga/SagaAlgorithmProvider.py", line 77, in _loadAlgorithms
    version = SagaUtils.getSagaInstalledVersion(True)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/algs/saga/SagaUtils.py", line 128, in getSagaInstalledVersion
    lines = proc.readlines()
IOError: [Errno 4] Interrupted system call

and

Traceback (most recent call last):
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 228, in startPlugin
    plugins[packageName].initGui()
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/ProcessingPlugin.py", line 57, in initGui
    Processing.initialize()
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/core/Processing.py", line 136, in initialize
    Processing.addProvider(SagaAlgorithmProvider())
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/core/Processing.py", line 96, in addProvider
    % (provider.getDescription(), unicode(sys.exc_info()[1])))
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/algs/saga/SagaAlgorithmProvider.py", line 108, in getDescription
    version = SagaUtils.getSagaInstalledVersion()
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/algs/saga/SagaUtils.py", line 128, in getSagaInstalledVersion
    lines = proc.readlines()
IOError: [Errno 4] Interrupted system call

#3 Updated by William Kyngesburye over 8 years ago

One last bit, it's probably nothing to do with compiling at all - it sometimes works when the .pyc is present, though more often it does not work. Without the pyc it's more like 50/50.

I'll try other OS X versions (different python 2.7 versions)...

#4 Updated by Giovanni Manghi over 8 years ago

  • Target version deleted (Version 2.10)

#5 Updated by Alexander Bruy almost 8 years ago

  • Resolution set to fixed/implemented
  • Status changed from Open to Closed

Should be fixed in 9074b14a74

Also available in: Atom PDF