Segfault when right clicking while dragging on canvas

I recently encountered this issue reported before in ROOT 6.02/08:
when dragging an object drawn on a canvas with the left mouse button (orange guidelines appear), then clicking the right button before releasing the left button (context menu appears), and then left clicking on the canvas again, a segfault occurs in TPad::ShowGuidelines(). Admittedly this is not the most useful sequence of mouse actions, but it sometimes happens by accident.

Since I don’t have a JIRA account, I thought I’d post here what I think is happening that causes this crash.
When dragging and object, TPad::ShowGuidelines() draws the guidelines on a temporary transparent TPad that is normally deleted on a subsequent kButton1Up mouse event when dragging stops. However, when the right mouse button is clicked while the left button has not been released yet, no such mouse event reaches the dragged object. So the temporary guidelines pad is not deleted (guidelines remain visible) and the next left click on the canvas will grab this pad instead. This also causes a call to ShowGuideLines() and one of the first things this function does is delete any previous temporary guidelines pad (TPad.cxx:5747). So actually the this pointer is deleted and a segfault occurs a few lines down when the this pointer is inspected for a dynamic_cast (TPad.cxx:5756).

Workaround: don’t click the right mouse button before releasing the left … or disable guideline drawing.

Thanks for the details. I found a two buttons mouse and I can reproduce it on Mac too.
I will look.

Now fixed (in 5.34, 6.02, 6.04). Thanks for reporting.