Ticket #8177 (closed: fixed)

Opened 7 years ago

Last modified 5 years ago

Python algorithm overwriting C++ loader causes crash on running Load

Reported by: Martyn Gigg Owned by: Martyn Gigg
Priority: major Milestone: Release 3.0
Component: Python Keywords:
Cc: Blocked By:
Blocking: Tester: Arturs Bekasovs

Description

When a Python algorithm has the same name and version as a C++ algorithm that is defined as a file loader, the Python alg silently overwrites the C++ one and crashes the file loader search.

To reproduce, put the code below in a file called LoadEventNexus.py and put it in the python plugins directory. Start MantidPlot and try to load any nexus file with Load and Mantid will crash

from mantid.kernel import *
from mantid.api import *

class LoadEventNexus(PythonAlgorithm):

    def PyInit(self):
      pass

    def PyExec(self):
      pass

AlgorithmFactory.subscribe(LoadEventNexus)

Change History

comment:1 Changed 7 years ago by Martyn Gigg

  • Status changed from new to inprogress

Unsubscribe any loader that has been replaced by a Python algorithm.

If we don't then we get a crash in the FileLoaderRegistry that tries to cast to an incorrect type.

Refs #8177

Changeset: 3743bd34e97e02f92fd9bcb8547ef7cb7a9ce9f0

comment:2 Changed 7 years ago by Martyn Gigg

  • Status changed from inprogress to verify
  • Resolution set to fixed

Branch: bugfix/8177_pyalg_overwrite_cpp_loader_crash

Tester: Use the above python algorithm to confirm that when it is in the python plugins directory it removes LoadEventNexus from being usable by Load.

When you have confirmed that, close MantidPlot and add

    def version(self):
        return 2

to the class definition. Start MantidPlot and confirm that now LoadEventNexus version 1 can be used by Load again.

comment:3 Changed 7 years ago by Arturs Bekasovs

  • Status changed from verify to verifying
  • Tester set to Arturs Bekasovs

comment:4 Changed 7 years ago by Arturs Bekasovs

Confirmed that before changes were made Mantid is crashing when trying to launch Load.

After the changes the problem seems to be solved. LoadEventNexus is not being checked as potential loading algorithm and thus is not crashing.

Changing the version of the added Python algorithm does what is expected - LoadEventNexus v1 is being checked and nothing goes wrong. LoadEventNexus v2 is not being checked, as it is not registered as loading algorithm.

Overall, everything works as advertised, hence closing the ticket.

Last edited 7 years ago by Arturs Bekasovs (previous) (diff)

comment:5 Changed 7 years ago by Arturs Bekasovs

  • Status changed from verifying to closed

Merge remote-tracking branch 'origin/bugfix/8177_pyalg_overwrite_cpp_loader_crash'

Full changeset: 98c0b337f4860a5893c1923ee45a097a8b7b35ba

comment:6 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 9022

Note: See TracTickets for help on using tickets.