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

Paste selection from clipboard to QS window with text causes crash on 1.2.0 (4008) #1716

Closed
D-elias opened this issue Dec 12, 2013 · 19 comments
Labels
Milestone

Comments

@D-elias
Copy link

D-elias commented Dec 12, 2013

This crash happens every time the action "paste selection from clip board" tries to paste in to an open "QS window with text"
I saved the following QS commands to "Actions" and created a trigger to run all 4:
•Copy the url from the current web page to the clipboard.
•Open QS command window with text after delay.
*Paste selection from clip board after delay.
*Run Applescript after delay to key code "Escape" then "Right Arrow":
"delay 0.01
tell application "System Events" to key code 53
delay 0.01
tell application "System Events" to key code 124"

This brings all of the links on the current web page in the QS window list for faster "Quick look" browsing. It still works on 1.1.3 (4007) but crashes every time on the newest version.

OSX 10.9-Nothing was changed between versions of QS when testing was done after reboot.
Maybe "All Links" can be a future action.

12/12/13 06:22:40.463 Quicksilver[1562]: enable failed
12/12/13 06:22:40.463 Quicksilver[1562]: enable failed
12/12/13 06:22:40.899 Quicksilver[1562]: bad data for Apple URL pasteboard type
12/12/13 06:22:42.358 com.apple.launchd.peruser.501[151]: (com.blacktree.Quicksilver.102464[1562]) Job appears to have crashed: Segmentation fault: 11

@skurfer
Copy link
Member

skurfer commented Dec 12, 2013

How can I reproduce this? If I do…

  1. Current Web Page ⇥ Copy to Clipboard
  2. ⌘␣
  3. .
  4. ⌘V

There’s no crash.

Maybe "All Links" can be a future action.

I addressed that on the mailing list. But the crash shouldn’t happen.

@skurfer
Copy link
Member

skurfer commented Dec 12, 2013

I can get a crash, but not the way you describe. This seems to do it pretty reliably:

  1. Current Web Page ⇥ Copy to Clipboard
  2. Show the history window or run Clipboard Contents ⇥ Select in Command Window

@skurfer
Copy link
Member

skurfer commented Dec 12, 2013

I’ll document what I’ve found for others to see, but I’m nowhere near a fix. This might only apply to copying proxy objects.

  1. The object you copy is sent putOnPasteboard:…, which stores the application’s PID and the object’s address (line 296)
  2. When adding to the history, the Clipboard plug-in calls QSObject objectWithPasteboard:
  3. That method unpacks the PID and address and creates a new pointer to the object and returns it.

The problem is that the object being pointed to has been freed (or at least it will be before you get a chance to use it). If you debug the Clipboard plug-in and catch the EXC_BAD_ACCESS, you’ll see that it was trying to get [currentArray objectAtIndex:0], which is just pointing to garbage by then.

@D-elias
Copy link
Author

D-elias commented Dec 13, 2013

I made 4 QS commands with delay, 1 for each stage of the action to be executed at once. It is a gritty way but I could not get it to work with an Applescript. This way still causes a crash on the new version so I found a new way to execute the action. I had to save the Applescript as an application and add some “run in background only” code to the info.plist. This way works much better than the old way. The only issue now is the modifier being held down to activate it via an Abracadabra gesture interferes with the Applescript.

    <key>LSBackgroundOnly</key>
    <string>True</string>
--added to the following application’s info.plist


tell application "System Events" to key code 0 using {shift down, option down, control down, command down}
delay 0.1
tell application "System Events" to key code 19 using {shift down, control down}
delay 0.3
tell application "System Events" to key code 9 using command down
delay 0.1
tell application "System Events" to key code 53
delay 0.1
tell application "System Events" to key code 124


--Saved as application.

On Dec 12, 2013, at 14:41, Rob McBroom notifications@github.com wrote:

I’ll document what I’ve found for others to see, but I’m nowhere near a fix. This might only apply to copying proxy objects.

The object you copy is sent putOnPasteboard:…, which stores the application’s PID and the object’s address (line 296)
When adding to the history, the Clipboard plug-in calls QSObject objectWithPasteboard:
That method unpacks the PID and address and creates a new pointer to the object and returns it.
The problem is that the object being pointed to has been freed (or at least it will be before you get a chance to use it). If you debug the Clipboard plug-in and catch the EXC_BAD_ACCESS, you’ll see that it was trying to get [currentArray objectAtIndex:0], which is just pointing to garbage by then.


Reply to this email directly or view it on GitHub.

@skurfer
Copy link
Member

skurfer commented Dec 13, 2013

The only issue now is the modifier being held down to activate it via an Abracadabra gesture interferes with the Applescript.

I think you can get around that by adding a delay to the trigger, so you have time to let go of modifiers before the script runs. (Haven’t tested it.) But why are you still going through all this? As I said on the mailing list:

Current Web Page (Safari) ⇥ Show Contents

@D-elias
Copy link
Author

D-elias commented Dec 13, 2013

I thought that it was just an idea, will be very nice when it is implemented.
Current Web Page (Safari) ⇥ Show Contents

@skurfer
Copy link
Member

skurfer commented Dec 13, 2013

It wasn’t an idea. It’s something you can do right now.

@D-elias
Copy link
Author

D-elias commented Dec 13, 2013

Thank you sir for explaining that last piece to me.This entire time I had no idea… That is what makes Quicksilver so awesome! After using it for a long time, I am still learning new things. It really is like the small tree with giant roots.

@skurfer
Copy link
Member

skurfer commented Dec 16, 2013

@philostein pointed out another crash related to the Clipboard: The “Show Clipboard” internal command crashes immediately.

@skurfer
Copy link
Member

skurfer commented Dec 30, 2013

I tried malloc_history for the object causing the crash. Anyone want to take a look?

http://cl.ly/text/3U3T1f0j1G1g

From looking at it, I thought it might be as simple as adding the resolved object to the history instead of the proxy itself, but that doesn’t seem to matter.

@pjrobertson
Copy link
Member

So is this fixed by the recent fix I made, or still broken?

@skurfer
Copy link
Member

skurfer commented Jan 17, 2014

I’m not aware of anything recent that comes near the problem code. Which fix?

@pjrobertson
Copy link
Member

I meant the PR that was just merged - the ARC crash with toggle: and performSelector. #1724

@skurfer
Copy link
Member

skurfer commented Jan 18, 2014

Ah. No, that’s unrelated. I think. The history window doesn’t seem to crash any more, so maybe that was fixed.

See my comment above for some detail.

These two actions back-to-back still trigger the crash every time:

Current Web Page (Safari) ⇥ Show Contents
Clipboard Contents ⇥ Select in Command Window

Though I’m not convinced it’s the same crash as before. It seems to be complaining about sending identifier to random objects now.

@pjrobertson
Copy link
Member

Yuck.

@pjrobertson
Copy link
Member

...so the problem is with storing the QSObject address on the clipboard and just blindly assuming the object will stick around for ever. Of course, it doesn't.

If you comment out line 291 in QSObject_Pasteboard.m you'll see that 'fixes' it.
I guess pre-ARC we could actually retain the QSObject being promised to the pasteboard. That was going to be my suggested solution, but of course we can't do that with ARC.

Maybe we should drop it all together. Do you like the use of sscanf on line 58? ;-)

@pjrobertson
Copy link
Member

...all of this pretty much boils down to: how do we represent an object when not in memory... the age old problem :)

@skurfer
Copy link
Member

skurfer commented Feb 8, 2014

the problem is with storing the QSObject address on the clipboard and just blindly assuming the object will stick around for ever. Of course, it doesn’t.

Right. I tried adding it to an array, which keeps it around long enough to get returned, but it’s somehow still garbage by the time the clipboard plug-in tries to use it. But even if that worked, how would we clean up the array?

Maybe we should drop it all together.

It’s been a while. I’ll need to look through it again.

@philostein
Copy link
Contributor

I've been mashing my 'Execute Show Clipboard' trigger since 4009, and it's all good. Thanks!

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

No branches or pull requests

4 participants