Opened 6 years ago

Closed 6 years ago

#2305 closed defect (fixed)

Picking: index out of bounds

Reported by: Tristan Croll Owned by: Tom Goddard
Priority: normal Milestone:
Component: Graphics Version:
Keywords: Cc:
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

The following bug report has been submitted:
Platform:        Linux-3.10.0-957.12.2.el7.x86_64-x86_64-with-centos-7.6.1810-Core
ChimeraX Version: 0.91 (2019-08-06)
Description
Won't copy the entire log because it's huge (result of a 3-day continuous run), but I just encountered the below traceback using the swapaa mousemode. First time I've seen it.

swapaa mousemode /AB:111 GLN
Traceback (most recent call last):   File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/mouse_modes/mousemodes.py", line 460, in <lambda>     gw.mouseReleaseEvent = lambda e, s=self: s._dispatch_mouse_event(e, "mouse_up")   File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/mouse_modes/mousemodes.py", line 387, in _dispatch_mouse_event     f(MouseEvent(event, modifiers=modifiers))   File "/home/tic20/.local/share/ChimeraX/0.91/site-packages/chimerax/isolde/mousemodes.py", line 60, in mouse_up     self.mouse_select(event, mode, self.session, self.view)   File "/home/tic20/.local/share/ChimeraX/0.91/site-packages/chimerax/isolde/mousemodes.py", line 67, in mouse_select     pick = view.first_intercept(x, y, self._pick_exclude)   File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/core/graphics/view.py", line 743, in first_intercept     p = self.first_intercept_on_segment(xyz1, xyz2, exclude=exclude, beyond=beyond)   File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/core/graphics/view.py", line 757, in first_intercept_on_segment     p = self.drawing.first_intercept(xyz1, xyz2, exclude=exclude)   File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/core/graphics/drawing.py", line 986, in first_intercept     p = self.first_intercept_children(self.child_drawings(), mxyz1, mxyz2, exclude=exclude)   File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/core/graphics/drawing.py", line 1002, in first_intercept_children     p = d.first_intercept(cxyz1, cxyz2, exclude=exclude)   File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/core/graphics/drawing.py", line 986, in first_intercept     p = self.first_intercept_children(self.child_drawings(), mxyz1, mxyz2, exclude=exclude)   File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/core/graphics/drawing.py", line 1002, in first_intercept_children     p = d.first_intercept(cxyz1, cxyz2, exclude=exclude)   File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/atomic/structure.py", line 1695, in first_intercept     ppicks = self._position_intercepts(self.positions[pn], mxyz1, mxyz2, exclude)   File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/atomic/structure.py", line 1728, in _position_intercepts     p = d.first_intercept(xyz1, xyz2, exclude=exclude)   File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/atomic/structure.py", line 2060, in first_intercept     atom = self.visible_atoms[anum]   File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/atomic/molarray.py", line 155, in __getitem__     v = self._object_class.c_ptr_to_py_inst(self._pointers[i]) IndexError: index 1562 is out of bounds for axis 0 with size 1562 IndexError: index 1562 is out of bounds for axis 0 with size 1562 File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/atomic/molarray.py", line 155, in __getitem__ v = self._object_class.c_ptr_to_py_inst(self._pointers[i]) See log for complete Python traceback. 

OpenGL version: 3.3.0 NVIDIA 415.27
OpenGL renderer: TITAN Xp/PCIe/SSE2
OpenGL vendor: NVIDIA Corporation

Change History (6)

comment:1 by pett, 6 years ago

Component: UnassignedGraphics
Owner: set to Tom Goddard
Platform: all
Project: ChimeraX
Status: newassigned
Summary: ChimeraX bug report submissionPicking: index out of bounds

comment:2 by Tom Goddard, 6 years ago

Here's the more readable traceback with line breaks.

swapaa mousemode /AB:111 GLN
Traceback (most recent call last):
File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/mouse_modes/mousemodes.py", line 460, in <lambda> gw.mouseReleaseEvent = lambda e, s=self: s._dispatch_mouse_event(e, "mouse_up")
File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/mouse_modes/mousemodes.py", line 387, in _dispatch_mouse_event f(MouseEvent(event, modifiers=modifiers))
File "/home/tic20/.local/share/ChimeraX/0.91/site-packages/chimerax/isolde/mousemodes.py", line 60, in mouse_up self.mouse_select(event, mode, self.session, self.view)
File "/home/tic20/.local/share/ChimeraX/0.91/site-packages/chimerax/isolde/mousemodes.py", line 67, in mouse_select pick = view.first_intercept(x, y, self._pick_exclude)
File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/core/graphics/view.py", line 743, in first_intercept p = self.first_intercept_on_segment(xyz1, xyz2, exclude=exclude, beyond=beyond)
File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/core/graphics/view.py", line 757, in first_intercept_on_segment p = self.drawing.first_intercept(xyz1, xyz2, exclude=exclude)
File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/core/graphics/drawing.py", line 986, in first_intercept p = self.first_intercept_children(self.child_drawings(), mxyz1, mxyz2, exclude=exclude)
File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/core/graphics/drawing.py", line 1002, in first_intercept_children p = d.first_intercept(cxyz1, cxyz2, exclude=exclude)
File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/core/graphics/drawing.py", line 986, in first_intercept p = self.first_intercept_children(self.child_drawings(), mxyz1, mxyz2, exclude=exclude)
File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/core/graphics/drawing.py", line 1002, in first_intercept_children p = d.first_intercept(cxyz1, cxyz2, exclude=exclude)
File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/atomic/structure.py", line 1695, in first_intercept ppicks = self._position_intercepts(self.positions[pn], mxyz1, mxyz2, exclude)
File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/atomic/structure.py", line 1728, in _position_intercepts p = d.first_intercept(xyz1, xyz2, exclude=exclude)
File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/atomic/structure.py", line 2060, in first_intercept atom = self.visible_atoms[anum]
File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/atomic/molarray.py", line 155, in getitem v = self._object_class.c_ptr_to_py_inst(self._pointers[i]) IndexError: index 1562 is out of bounds for axis 0 with size 1562 IndexError: index 1562 is out of bounds for axis 0 with size 1562
File "/opt/UCSF/ChimeraX-daily/lib/python3.7/site-packages/chimerax/atomic/molarray.py", line 155, in getitem v = self._object_class.c_ptr_to_py_inst(self._pointers[i]) See log for complete Python traceback.

comment:3 by Tom Goddard, 6 years ago

This same bug was reported 1 year ago #1248.

It happens during a mouse hover when it is looking for an atom under the mouse in AtomDrawing.first_intercept(). It uses AtomDrawing attributions positions and visible_atoms which should always have the same length. It uses positions to determine which sphere is under the mouse, then uses that index into visible_atoms. These two arrays positions and visible_atoms are set during graphics update. It is possible for visible_atoms to shrink if atoms are deleted (such as was done by the swapaa command which is the last logged command in this bug report before the traceback). The visible_atoms is an Atoms collection that automatically shrinks when atoms are deleted. If after deleting atoms first_intercept() is called before a graphics redraw and the mouse is over one of the deleted atoms, then I would expect this error. The first intercept code should protect against this. It is pretty simple to handle this -- check if visible_atoms is shorter than the positions array. Then the question is what to do. Two possibilities are to return None as if there is no atom under the mouse position, or try to compute the new visible atoms and their positions. In general, Drawing.first_intercept() is intended to pick objects that were shown the last time the graphics was drawn (what is under the mouse). So neither option is great. A third option would be to use the positions of visible_atoms but ignore new atoms (for instance ones added by swapaa) which have not been shown yet.

The ISOLDE mousemode code is call first_intercept() apparently in mouse up. I don't know if that mouse mode deleted atoms (maybe it did the swapaa). I should look at the ISOLDE mouse mode code to understand how this happened.

The previous bug report showed no indication that atoms were deleted, just a PDB opened, a surface shown then hidden. Maybe an unlogged atom deletion was done. It is suspicious that in that bug the index error is one beyond the length of the array (length 776), and in this report also one beyond the length of the array (length 1562). Seems unlikely unless it was from a mouse mode that deleted just one atom.

in reply to:  4 ; comment:4 by Tristan Croll, 6 years ago

Oh! I didn’t actually notice the ISOLDE line there in the traceback - and I have no idea why it fired. That’s the mouse picking, which should be mapped to ctrl-left - don’t think I touched that at the time, though of course it’s possible. Only atom addition/deletion at the time was from swapaa, though (albeit lots of other edits earlier, including addition/removal of hydrogens and addition of some metal ions). But by the sound of your previous example that’s not the cause.

 


in reply to:  5 ; comment:5 by Tristan Croll, 6 years ago

I've tried a number of scenarios in an attempt to replicate this today, 
and haven't found anything (and this is the first time in probably 
thousands of similar interactions that I've seen this error). Whatever's 
causing it, it seems to be an *extremely* rare set of circumstances.

On 2019-08-13 06:39, ChimeraX wrote:

comment:6 by Tom Goddard, 6 years ago

Resolution: fixed
Status: assignedclosed

Fixed.

If atoms are deleted and a pick is done before the graphics is updated then it will not pick any atom. Not ideal, but handling this extremely rare case better will introduce code that is almost never tested and therefore likely to be buggy.

Note: See TracTickets for help on using tickets.