Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pymol --testing destroys SingletonPyMOLGlobals #335

Open
speleo3 opened this issue Feb 2, 2024 · 2 comments
Open

pymol --testing destroys SingletonPyMOLGlobals #335

speleo3 opened this issue Feb 2, 2024 · 2 comments

Comments

@speleo3
Copy link
Contributor

speleo3 commented Feb 2, 2024

Summary

Looks like the C++ tests can destroy SingletonPyMOLGlobals. I suspect since 4e3097f.

Steps to reproduce

  • pymol --testing

Observed output

python: layer1/P.cpp:1914: void PInit(PyMOLGlobals*, int): Assertion `SingletonPyMOLGlobals' failed.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pymol is a Catch v2.13.10 host application.
Run with -? for options

-------------------------------------------------------------------------------
ExecutiveManageObject
-------------------------------------------------------------------------------
layerCTest/Test_Executive.cpp:27
...............................................................................

layerCTest/Test_Executive.cpp:27: FAILED:
due to a fatal error condition:
  SIGABRT - Abort (abnormal termination) signal

===============================================================================
test cases:  16 |  15 passed | 1 failed
assertions: 150 | 149 passed | 1 failed

Aborted (core dumped)

Crash observed on

  • PyMOL 2.6.0a0 Open-Source (3faec30816), 2024-02-02
  • Arch Linux, Python 3.11.6
  • macOS 14.2.1 with Homebrew, Python 3.11.6

Possible root cause

PInit() overwrites pymol.cmd._COb (without a destructor).

pymol-open-source/layer1/P.cpp

Lines 1916 to 1917 in 3faec30

PyObject_SetAttrString(P_cmd, "_COb",
PyCapsule_New(&SingletonPyMOLGlobals, nullptr, nullptr));

The overwritten _COb was probably previously initialized in Cmd_New, with a destructor.

return PyCapsule_New(
PyMOL_GetGlobalsHandle(I), nullptr, PyMOLGlobalsCapsuleDestructor);

@JarrettSJohnson
Copy link
Member

JarrettSJohnson commented Feb 2, 2024

Thanks for opening this issue. There was a commit that I forgot to transfer here which includes the following

   PyMOLInstance::PyMOLInstance()
   {
     auto options = PyMOLOptions_New();
     options->show_splash = false;
     m_Inst = PyMOL_NewWithOptions(options);
     PyMOLOptions_Free(options);
     m_G = PyMOL_GetGlobals(m_Inst);
+    SingletonPyMOLGlobals = m_G;
     PInit(m_G, true);
     PyMOL_Start(m_Inst);
   }

   PyMOLInstance::~PyMOLInstance()
   {
     PyMOL_Stop(m_Inst);
     PFree(m_G);
     PyMOL_Free(m_Inst);
+    SingletonPyMOLGlobals = nullptr;
   }

was written some time ago, and looking back on it now, I'm not confident that it's the correct strategy.

Edit: if I don't have a proper solution by the end of the weekend, I'll disable this test for the time being.

@JarrettSJohnson
Copy link
Member

I've silenced the tests that use PyMOLInstance for now just so that the suite can pass on these machines. I'll look into fixing the underlying issue soon when I get some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants