Skip to content

std: Don't deadlock/panic on recursive prints#23798

Merged
bors merged 1 commit into
rust-lang:masterfrom
alexcrichton:issue-23781
Mar 28, 2015
Merged

std: Don't deadlock/panic on recursive prints#23798
bors merged 1 commit into
rust-lang:masterfrom
alexcrichton:issue-23781

Conversation

@alexcrichton

Copy link
Copy Markdown
Member

Previously a panic was generated for recursive prints due to a double-borrow of
a RefCell. This was solved by the second borrow's output being directed
towards the global stdout instead of the per-thread stdout (still experimental
functionality).

After this functionality was altered, however, recursive prints still deadlocked
due to the overridden write_fmt method which locked itself first and then
wrote all the data. This was fixed by removing the override of the write_fmt
method. This means that unlocked usage of write! on a Stdout/Stderr may be
slower due to acquiring more locks, but it's easy to make more performant with a
call to .lock().

Closes #23781

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@aturon

aturon commented Mar 27, 2015

Copy link
Copy Markdown
Contributor

We could eventually use a re-entrant lock, as well, but this is fine for now.

@bors: r+ 2191701

@bors

bors commented Mar 28, 2015

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #23796) made this pull request unmergeable. Please resolve the merge conflicts.

Previously a panic was generated for recursive prints due to a double-borrow of
a `RefCell`. This was solved by the second borrow's output being directed
towards the global stdout instead of the per-thread stdout (still experimental
functionality).

After this functionality was altered, however, recursive prints still deadlocked
due to the overridden `write_fmt` method which locked itself first and then
wrote all the data. This was fixed by removing the override of the `write_fmt`
method. This means that unlocked usage of `write!` on a `Stdout`/`Stderr` may be
slower due to acquiring more locks, but it's easy to make more performant with a
call to `.lock()`.

Closes rust-lang#23781
@alexcrichton

Copy link
Copy Markdown
Member Author

@bors: r=aturon e2fd2df

@bors

bors commented Mar 28, 2015

Copy link
Copy Markdown
Collaborator

⌛ Testing commit e2fd2df with merge 9f9e251...

bors added a commit that referenced this pull request Mar 28, 2015
Previously a panic was generated for recursive prints due to a double-borrow of
a `RefCell`. This was solved by the second borrow's output being directed
towards the global stdout instead of the per-thread stdout (still experimental
functionality).

After this functionality was altered, however, recursive prints still deadlocked
due to the overridden `write_fmt` method which locked itself first and then
wrote all the data. This was fixed by removing the override of the `write_fmt`
method. This means that unlocked usage of `write!` on a `Stdout`/`Stderr` may be
slower due to acquiring more locks, but it's easy to make more performant with a
call to `.lock()`.

Closes #23781
@bors

bors commented Mar 28, 2015

Copy link
Copy Markdown
Collaborator

@bors bors merged commit e2fd2df into rust-lang:master Mar 28, 2015
@alexcrichton alexcrichton deleted the issue-23781 branch April 2, 2015 19:45
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

Successfully merging this pull request may close these issues.

Nested println!() statements fail

4 participants