Skip to content
GitLab Next
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab FOSS GitLab FOSS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.org
  • GitLab FOSSGitLab FOSS
  • Issues
  • #61432
Closed
Open
Created May 05, 2019 by Stan Hu@stanhuOwner

lib/tasks/lint.rake can block indefinitely if stderr fills up

I made the mistake of generating .rubocop_todo.yml with a newer version of rubocop-rspec present, and this introduced unrecognized cops that the haml_lint task complained about. Since haml_lint runs Rubocop in a way that causes config values to be re-read every file (https://github.com/sds/haml-lint/issues/301), I think the static-analysis jobs got stuck. I suspect the stderr pipe filled up, and the PID never stopped.

This patch seems to make things go again:

diff --git a/lib/tasks/lint.rake b/lib/tasks/lint.rake
index fa45b092833..7aab53491e6 100644
--- a/lib/tasks/lint.rake
+++ b/lib/tasks/lint.rake
@@ -37,14 +37,8 @@ unless Rails.env.production?
         lint:static_verification
       ].each do |task|
-        pid = Process.fork do
-          rd_out, wr_out = IO.pipe
-          rd_err, wr_err = IO.pipe
-          stdout = $stdout.dup
-          stderr = $stderr.dup
-          $stdout.reopen(wr_out)
-          $stderr.reopen(wr_err)

+        pid = Process.fork do
           begin
             Rake::Task[task].invoke
           rescue SystemExit => ex
@@ -54,15 +48,7 @@ unless Rails.env.production?
             msg = "*** Rake task #{task} raised #{ex.class}:"
             raise ex
           ensure
-            $stdout.reopen(stdout)
-            $stderr.reopen(stderr)
-            wr_out.close
-            wr_err.close
-
             warn "\n#{msg}\n\n" if msg
-
-            IO.copy_stream(rd_out, $stdout)
-            IO.copy_stream(rd_err, $stderr)
           end
         end

@rymai @godfat I tested these changes locally, and they seem to do the right thing. I wasn't able to reproduce the same issues as mentioned in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16732#note_58996412.

Edited May 05, 2019 by Stan Hu
Assignee
Assign to
Time tracking