Skip to content

Hold stderr lock when using stdout through Console APIs. - #17360

Merged
bors-servo merged 1 commit into
masterfrom
stderr
Jun 17, 2017
Merged

bors-servo merged 1 commit into
masterfrom
stderr

Conversation

@jdm

@jdm jdm commented Jun 16, 2017 •

Copy link
Copy Markdown
Member

This addresses a longstanding source of intermittent test failures where the stderr and stdout outputs get interleaved and the test harness becomes confused.



This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/console.rs
  • @KiChjang: components/script/dom/console.rs

@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jun 16, 2017
}
}

fn with_stderr_lock<F>(f: F) where F: FnOnce() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment here on why is it needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Self::send_to_devtools(global, LogLevel::Log, message);
}
with_stderr_lock(move || {
for message in messages {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I wonder whether we should split this loop (and the others) into two, one that does the printing with the lock held, and other that calls send_to_devtools.

I say that, because as far as I can tell, that function can panic and log (it uses downcast, which calls get_dom_class, which does trace!, which writes to stderr I think). I'd expect this to deadlock with RUST_LOG=trace, wouldn't it? or is the lock re-entrant? If it is, please comment on it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stderr lock is reentrant, yes.

@emilio

emilio commented Jun 17, 2017

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit b29d0c6 has been approved by emilio

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jun 17, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit b29d0c6 with merge d388dc9...

bors-servo pushed a commit that referenced this pull request Jun 17, 2017
Hold stderr lock when using stdout through Console APIs.

This addresses a longstanding source of intermittent test failures where the stderr and stdout outputs get interleaved and the test harness becomes confused.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #12797
- [X] There are tests for these changes

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17360)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev
Approved by: emilio
Pushing d388dc9 to master...

@bors-servo
bors-servo merged commit b29d0c6 into master Jun 17, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jun 17, 2017
@SimonSapin
SimonSapin deleted the stderr branch June 26, 2017 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants