schrodinger / pymol-open-source

Open-source foundation of the user-sponsored PyMOL molecular visualization system.
https://pymol.org/
Other
1.15k stars 275 forks source link

Bizarre invalid selection / selection just gives up #336

Open bcov77 opened 7 months ago

bcov77 commented 7 months ago

Hi,

I'm been using pymol for a long time, using original PyMOL 1 and PyMOL 2 on El Capitan. I recently had to update my mac to Monterey, and now, pymol crashes in bizarre ways.

Here's a minimal test snippet that will crash for me (regardless of what protein is displayed (even none)):

for i in range(100):
    print(i)
    cmd.select("test", "name h") # note, it doesn't matter what you select here
    cmd.select("test", "test")  # I think this is the main line that causes the issue
    cmd.delete("test")

pymol.CmdException:  Error: Invalid selection name "test"

Notably, this doesn't crash on i == 0. It crashes on i == 11.

This snippet crashes in the gui (whether you 1-line it for the command prompt or put it in a script and call run) in both open source and closed source versions. I've tried both 2.5.7 and 2.5.8.

Once you get into this state. There's a broken selection called "test" that displays in the gui (and displays in cmd.get_names()), but clearly is broken because pymol throws an error when you click on the "A" button.

Screen Shot 2024-02-10 at 3 10 22 PM

I do not get this crash or the glitchy selection when running these snippets from the commandline (using ipython and import pymol). It also does not crash when running in my .pymolrc and launching the gui.

Debugging

This snippet does not crash:

for i in range(100):
    print(i)
    cmd.select("test", "name h")
    cmd.select("test", "test")
    cmd.delete("test")

    cmd.select("asdf", "name o")
    cmd.select("asdf")

Then, it gets weirder. If you run that bad line multiple times, you have to fix it multiple times.

A = 1
B = 1
for i in range(100):
    print(i)
    cmd.select("test", "name h")
    for j in range(A):
        cmd.select("test", "test")
    cmd.delete("test")

    cmd.select("asdf", "name o")
    for j in range(B):
        cmd.select("asdf")

Here's a table with the minimum values of B I could get this to NOT crash at for a given value of A. These values are the same in both the closed and open source versions.

   A   B
   1   1
   2   1
   3   3
   4   3
   5   5
   6   4
   7   4
   8   3
   9   2
  10   9
  11   8
  12   8
  13   7
  14   7
  15   0 # It just works?!?!?! Original snippet doesn't crash
# And from here on, it just works

But once you call that command 15 times, it just works. (i.e. if A is >= 15, B can be 0)

Anyways, I'm happy to help get this bug fixed. Or, please just tell me how to remove all traces of pymol from my computer so I can reinstall. I've tested with some other people and these bugs don't exist. I don't know what's wrong with my install.