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

Crashes randomly when working with a background queue #17

Open
DevAlansc opened this issue Oct 17, 2016 · 5 comments
Open

Crashes randomly when working with a background queue #17

DevAlansc opened this issue Oct 17, 2016 · 5 comments

Comments

@DevAlansc
Copy link

Hi guys,

I've been using this library for some months and I really like it. Unfortunately, I start having some crashes in the latest versions (Currently, I'm using the version 1.0.3).

I don't receive an exception, only a signal: EXC_BAD_ACCESS. Please, see the attached images.

first_image

step 2

step 3

The first image shows how the tasks are added to the queue in background mode.
The other ones show where the lib fails.

Could you give me any suggestion? I don't have any idea about what can be failing Many thanks.

@calvadoser
Copy link

Having the same issue, @DevAlansc @icanzilb did you find any solution for that ?
Thanks.

@icanzilb
Copy link
Owner

If there is an error trace or other more informative error, this potentially could be addressed

@mzbik
Copy link

mzbik commented May 10, 2017

I think it will be hard to come up with a trace; I believe there are a number of multithreaded race conditions in the code due to >all< accesses to arrays not being protected. Looking at the code more:

  1. hasCompletions is never reset. Seems like a needless optimization...
  2. you are calling completions while synchronized. Could you run into deadlocks?
  3. calls to .insert(at:), .remove(at:) and .removeAll are not synchronized
  4. the += operator on tasks and completions is not synchronized

I believe there are other races as well since the public methods themselves are not synchronized

@alexandremorgado
Copy link

Having the same issue here, too. I've been using this awesome class on my download manager, to queue a large number of image downloads on background (usually more them 1.000 images). But I had to limit maximumNumberOfActiveTasks to 3. If a set to 10 active tasks, sometimes the app crash.

@DouweBos
Copy link

I just replaced TaskQueue with the following: https://github.com/couchdeveloper/TaskQueue

So far it's no longer randomly crashing

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