diff --git a/CHANGELOG.md b/CHANGELOG.md index edc5cc88..8fac916d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Add `RubySyntax` pre-commit hook * Relax `childprocess` dependency to allow version 1.x * Add `CodeSpellCheck` pre-commit hook +* Fix deadlock which was more likely to occur when setting `parallelize` on a hook to `false` ## 0.48.1 diff --git a/lib/overcommit/hook_runner.rb b/lib/overcommit/hook_runner.rb index 16af2c23..8ac01e99 100644 --- a/lib/overcommit/hook_runner.rb +++ b/lib/overcommit/hook_runner.rb @@ -129,12 +129,9 @@ def release_slot(hook) slots_released = processors_for_hook(hook) @slots_available += slots_released - if @hooks_left.any? - # Signal once. `wait_for_slot` will perform additional signals if - # there are still slots available. This prevents us from sending out - # useless signals - @resource.signal - end + # Signal every time in case there are threads that are already waiting for + # these slots to be released + @resource.signal end end diff --git a/spec/integration/parallelize_spec.rb b/spec/integration/parallelize_spec.rb index 4cf4c52d..20a86be3 100644 --- a/spec/integration/parallelize_spec.rb +++ b/spec/integration/parallelize_spec.rb @@ -7,10 +7,16 @@ subject { shell(%w[git commit --allow-empty -m Test]) } let(:config) { <<-YML } + concurrency: 20 CommitMsg: TrailingPeriod: enabled: true parallelize: false + command: ['ruby', '-e', 'sleep 1'] + TextWidth: + enabled: true + parallelize: true + processors: 1 YML around do |example| @@ -22,6 +28,7 @@ end it 'does not hang' do - Timeout.timeout(5) { subject } + result = Timeout.timeout(5) { subject } + result.stderr.should_not include 'No live threads left. Deadlock?' end end