-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Sparkle runs thread-unsafe code on secondary threads #6
Comments
As a partial fix for the most critical part, here's a thread-safe BOOL SUCopyObjectAtURLToDirectoryAtURL(NSURL _srcURL, NSURL *dstURL, NSError *_error)
} Originally posted on Launchpad by Hofman (cmhofman) at Sat Jun 20 05:44:40 -0700 2009 |
NSFileManager is only thread-unsafe if you're relying on the delegate to Originally posted on Launchpad by Paul Marks (shadowofged) at Sun Jun 21 01:20:03 -0700 2009 |
Where did you read that? Because I did not see that anywhere in the Apart from that, the most critical methods I'm talking about DO take a And using a second NSFileManager is only supported since 10.5, while Originally posted on Launchpad by Hofman (cmhofman) at Sun Jun 21 02:07:27 -0700 2009 |
Some more hints how to solve this. I'm hesitant to fix this in my copy, Basically all file copies can be replaced by FSCopyObjectSync, and the To check for write access use access([path fileSystemRepresentation], To create a temporary directory (is this really necessary on the To delete a temporary directory, you can check the sample code in To check whether a file exists, you can simply use FSPathMakeRef, if it To enumerate a directory, use FSOpenIterator, the docs have a generic You may decide to simply do the releaseFromQuarantine using And what's the NSFileSize check in SUPipedUnarchiver for? The returned Originally posted on Launchpad by Hofman (cmhofman) at Sat Jun 27 03:08:13 -0700 2009 |
Ugh, this is disgusting. I wonder how bad it would be to just run it synchronously. I'm not sure Originally posted on Launchpad by Andy Matuschak (andymatuschak) at Mon Jul 06 23:36:45 -0700 2009 |
Concurrency, at least as far as the file access is concerned, should not I was also wondering if it could run synchronously, it's also something However copying a whole (potentially big) bundle could be slow, remember Originally posted on Launchpad by Hofman (cmhofman) at Tue Jul 07 02:32:33 -0700 2009 |
I've attached a thread safe version of SUDiskImageUnarchiver.m, using I think this is the most important one that you may want to leave async. Note that I removed the lines creating a folder at the mount point. That And note that you need to link CoreServices (or Carbon) to use this. Originally posted on Launchpad by Hofman (cmhofman) at Tue Jul 07 05:59:19 -0700 2009 |
Attached another version of SUDiskImageUnarchiver.m. Forgot to assign Originally posted on Launchpad by Hofman (cmhofman) at Tue Jul 07 11:06:06 -0700 2009 |
Attached a thread safe version of SUPlainInstallerInternals.m using Originally posted on Launchpad by Hofman (cmhofman) at Tue Jul 07 13:01:21 -0700 2009 |
And a thread safe version of SUPlainInstaller.m, making sure the The only other change necessary apart from these three is Originally posted on Launchpad by Hofman (cmhofman) at Tue Jul 07 14:25:20 -0700 2009 |
Here's an even better solution for SUPlainInstaller. It uses the old Originally posted on Launchpad by Hofman (cmhofman) at Wed Jul 08 06:08:56 -0700 2009 |
Oops, moved the wrong file. Also another effort duplication removed. Originally posted on Launchpad by Hofman (cmhofman) at Wed Jul 08 07:13:54 -0700 2009 |
Here are all the necessary changes combined into a patch Originally posted on Launchpad by Hofman (cmhofman) at Wed Jul 08 14:15:23 -0700 2009 |
Wow, in fact FSCopyObjectSync, unlike NSFileManager, does allow copying Small correction in SUPlainInstaller: in my version nil values can be Sorry for the many versions. Originally posted on Launchpad by Hofman (cmhofman) at Thu Jul 09 10:54:37 -0700 2009 |
Hofman, don't be sorry—thanks for doing the legwork on this one! It may Originally posted on Launchpad by Andy Matuschak (andymatuschak) at Thu Jul 09 11:26:22 -0700 2009 |
Just noticed that FSMoveObjectToTrashSync() is Leopard-only. That could Originally posted on Launchpad by Hofman (cmhofman) at Mon Jul 13 09:55:49 -0700 2009 |
See bug #388793 for a consequence of this bug, though this does not even
touch the real problem. As the problem is more widespread and lies
deeper I open a new more comprehensive bug.
Sparkle runs code that can only be used on the main thread on secondary
threads. This happens (for sure) in SUPlainInstaller,
SUDiskImageUnarchiver, and SUPipedArchiver.
The clearest problem is the use of shared instances of thread-unsafe
classes, such as NSFileManager, NSWorkspace, and NSBundle, either
directly or indirectly. You can use these instances ONLY on the main
thread, because they're the same objects that are already used for sure
on the main thread.
I can only see three ways to fix this (may depend on the particular instance):
Migrated from Launchpad: https://bugs.launchpad.net/sparkle/+bug/389869
Originally reported by Hofman (cmhofman) at Sat, 20 Jun 2009 12:05:18 -0000.
The text was updated successfully, but these errors were encountered: