Skip to content

Make sure we re-acquire lock if a task throws#6565

Merged
laanwj merged 1 commit into
bitcoin:masterfrom
casey:scheduler-lock
Aug 19, 2015
Merged

Make sure we re-acquire lock if a task throws#6565
laanwj merged 1 commit into
bitcoin:masterfrom
casey:scheduler-lock

Conversation

@casey

@casey casey commented Aug 17, 2015

Copy link
Copy Markdown
Contributor

This fixes #6394

Pretty simple, it just makes sure to re-acquire the lock in case f throws, so that we don't touch nThreadsServicingQueue without the lock. The empty throw statement re-raises the current exception.

@sipa

sipa commented Aug 17, 2015

Copy link
Copy Markdown
Member

utACK.

@dcousens

Copy link
Copy Markdown
Contributor

Couldn't this be done using a scope bound, RAII locking mechanism instead?

utACK

@casey

casey commented Aug 18, 2015

Copy link
Copy Markdown
Contributor Author

@dcousens: Oh, hey, it looks like there actually is a reverse lock: http://www.boost.org/doc/libs/1_55_0/doc/html/thread/synchronization.html#thread.synchronization.other_locks.reverse_lock

I'll reimplement tomorrow, should be much cleaner.

@sipa

sipa commented Aug 18, 2015 via email

Copy link
Copy Markdown
Member

@casey

casey commented Aug 18, 2015

Copy link
Copy Markdown
Contributor Author

Re-wrote it with a reverse_lock, it's much nicer now

@sipa

sipa commented Aug 18, 2015 via email

Copy link
Copy Markdown
Member

@dcousens

Copy link
Copy Markdown
Contributor

utACK, good find @casey

@laanwj

laanwj commented Aug 19, 2015

Copy link
Copy Markdown
Member

/me really likes this solution. An inverse lock :-)
utACK.

@laanwj laanwj merged commit fb08d92 into bitcoin:master Aug 19, 2015
laanwj added a commit that referenced this pull request Aug 19, 2015
fb08d92 Make sure we re-acquire lock if a task throws (Casey Rodarmor)
@laanwj laanwj added the Bug label Aug 19, 2015
@theuni

theuni commented Aug 20, 2015

Copy link
Copy Markdown
Member

boost::reverse_lock is new as of 1.50 :(

We either need to set that as the minimum version required or work out a different fix here.

@casey

casey commented Aug 20, 2015

Copy link
Copy Markdown
Contributor Author

The reverse lock implementation is very simple. If we can't bump the minimum required boost version to 1.50, I could copy pasta it in.

Alternatively we could just go back to the first implementation, which, although ugly, works fine.

@dcousens

Copy link
Copy Markdown
Contributor

I see no reason why we wouldn't be able to bump?

@pstratem

Copy link
Copy Markdown

Debian wheezy is 1.49 please do not bump the required version.

@jonasschnelli

Copy link
Copy Markdown
Contributor

Also ran into the same problem like @pstratem. I solved it with a dist upgrade to jessie... which is somehow not ideal. Support for boost 1.49 would be good but not urgently necessary.

@dcousens

Copy link
Copy Markdown
Contributor

Boost 1.49 was released on February 24th, 2012.
Boost 1.50 was released on June 28th, 2012.
Debian 7.8 was released on January 10th, 2015.

Why the lag on a 4-month older package?

@casey

casey commented Aug 31, 2015

Copy link
Copy Markdown
Contributor Author

Opened PR #6608, to revert and fix without a boost dependency.

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Race condition in CScheduler::serviceQueue

8 participants