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

Bizarre invalid selection / selection just gives up #336

Open
bcov77 opened this issue Feb 10, 2024 · 10 comments
Open

Bizarre invalid selection / selection just gives up #336

bcov77 opened this issue Feb 10, 2024 · 10 comments

Comments

@bcov77
Copy link

bcov77 commented Feb 10, 2024

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.

@EvanKomp
Copy link

EvanKomp commented Jan 6, 2025

I am observing this too.

@bcov77
Copy link
Author

bcov77 commented Jan 6, 2025

It's not just me!

For reference this issue has never gone away, it just comes and goes sometimes.

@JarrettSJohnson
Copy link
Member

JarrettSJohnson commented Jan 6, 2025

@EvanKomp Are you also observing this only on Mac?

@pslacerda
Copy link
Contributor

In my case, I have an object named prot and another named lig. On some cases I can't select prot lig because it raises pymol.CmdException: Error: Invalid selection name "lig". The only workaround is to select * instead of prot lig what otherwise should be the same as they are the only objects as tell cmd.get_object_list.

@pslacerda
Copy link
Contributor

I'm using Fedora 39 with Python 3.10.16 and PyMOL 3.1.3.

@colinasmith
Copy link

I ran into this exact same issue. If I repeatedly paste the following into the command line on PyMOL 3.1.3 (incentive version) on macOS Sonoma, it will give a selection not found error every four times:

delete all
fetch 1WWW
util.color_chains("(1WWW and elem C)")
show sticks, /1WWW//X/294+296+333

I think it may have something to do with the undo feature. The problem goes away by disabling undo support:

cmd.undo_disable()

@TstewDev
Copy link
Collaborator

I can confirm that I see the error about every four times using that short script repeatedly and it does disappear after disabling undo. This is using incentive PyMOL 3.1.3.1 and macOS Sequoia 15.3.

Disabling Undo before running the original script in the thread also fixes the issue.

I'll create an internal ticket and investigate the issue, though this may take some time if it's some undefined behavior with Undo.

Once I confirm this is definitely related to Undo, I'll close this ticket since it's an incentive only feature, but I will update this thread once there's a fix version.

Thank you everyone for reporting this and helping to narrow down a potential cause!

@colinasmith
Copy link

After the problem rears its head, it also appears to interfere with the "Action" button at least on objects where the selection is invalid. Pressing that button gives the following error:

Traceback (most recent call last):
  File "/Applications/PyMOL.app/Contents/lib/python3.10/site-packages/pmg_qt/contents_panel/ASHLC_button.py", line 175, in _btn_clicked
    self.submenu_list = self._get_submenu_option_list()
  File "/Applications/PyMOL.app/Contents/lib/python3.10/site-packages/pymol/panel.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "/Applications/PyMOL.app/Contents/lib/python3.10/site-packages/pmg_qt/contents_panel/ASHLC_button.py", line 214, in _get_submenu_option_list
    return option_list_func() if option_list_func else []
  File "/Applications/PyMOL.app/Contents/lib/python3.10/site-packages/pmg_qt/contents_panel/ASHLC_button.py", line 241, in get_action_list
    return obj_action(self.cmd, self.rec.name) if obj_action else []
  File "/Applications/PyMOL.app/Contents/lib/python3.10/site-packages/pymol/menu.py", line 1352, in mol_action
    [ 1, 'copy to object' , copy_to(self_cmd, sele) ],
  File "/Applications/PyMOL.app/Contents/lib/python3.10/site-packages/pymol/menu.py", line 1225, in copy_to
    ] + [
  File "/Applications/PyMOL.app/Contents/lib/python3.10/site-packages/pymol/menu.py", line 1228, in <listcomp>
    if oname not in selected
TypeError: argument of type 'NoneType' is not iterable

If it's going to take a while to fix, I'd suggest putting a note somewhere obvious for incentive users that the "Undo" feature in the incentive version is buggy and should be disabled if users encounter problems.

@pslacerda
Copy link
Contributor

Here a excerpt from the console when I load the attached .pdb file without doing cmd.undo_disable() first.

PyMOL>load 7UKK_A_atlas.pdb
HEADER protein
HEADER consensus.000.023
HEADER consensus.001.015
HEADER consensus.002.015
HEADER consensus.003.015
HEADER consensus.004.011
HEADER consensus.005.006
HEADER consensus.006.006
HEADER consensus.007.002
 CmdLoad: loaded 9 objects from "".
 Selector-Error: Invalid selection name "7UKK_A_atlas".
7UKK_A_atlas<--

@bcov77
Copy link
Author

bcov77 commented Feb 11, 2025

I can confirm that the "undo" button seems to explain my problem as well.

I had noticed that this problem went away a few months ago on it's own, but I think it's just because Undo has been disabled. Reason: Memory exceeded.

With undo disabled, I don't have this bug. With undo enabled, I have this bug.

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

6 participants