Skip to content

Commit fa6a22f

Browse files
committed
---
yaml --- r: 236524 b: refs/heads/tmp c: 3b42b60 h: refs/heads/master v: v3
1 parent 312815f commit fa6a22f

File tree

7 files changed

+92
-36
lines changed

7 files changed

+92
-36
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: d2e13e822a73e0ea46ae9e21afdd3155fc997f6d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: 4f15e465e5e838aa2a57cccf57af241699d68f51
28+
refs/heads/tmp: 3b42b60bf675214d668b92b4791d58b63b143f40
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/mk/grammar.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ check-lexer: $(BG) $(BG)RustLexer.class check-build-lexer-verifier
5858
$(Q)$(SG)check.sh $(S) "$(BG)" \
5959
"$(CFG_GRUN)" "$(BG)verify" "$(BG)RustLexer.tokens"
6060
else
61-
$(info cfg: lexer tooling not available, skipping lexer test...)
61+
$(info cfg: grun not available, skipping lexer test...)
6262
check-lexer:
6363

6464
endif
6565
else
66-
$(info cfg: lexer tooling not available, skipping lexer test...)
66+
$(info cfg: antlr4 not available, skipping lexer test...)
6767
check-lexer:
6868

6969
endif
7070
else
71-
$(info cfg: lexer tooling not available, skipping lexer test...)
71+
$(info cfg: javac not available, skipping lexer test...)
7272
check-lexer:
7373

7474
endif

branches/tmp/src/liblibc/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1683,10 +1683,12 @@ pub mod types {
16831683
pub mod posix01 {
16841684
use types::common::c95::{c_void};
16851685
use types::common::c99::{uint32_t, uint64_t};
1686-
use types::os::arch::c95::{c_int, c_uint, c_long, time_t};
1686+
use types::os::arch::c95::{c_long, time_t};
16871687
use types::os::arch::posix88::{dev_t, gid_t};
16881688
use types::os::arch::posix88::{mode_t, off_t};
16891689
use types::os::arch::posix88::{uid_t};
1690+
#[cfg(target_os = "netbsd")]
1691+
use types::os::arch::c95::{c_int, c_uint};
16901692

16911693
pub type nlink_t = uint32_t;
16921694
pub type blksize_t = uint32_t;

branches/tmp/src/librustc/middle/liveness.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,8 +1399,9 @@ fn check_arm(this: &mut Liveness, arm: &hir::Arm) {
13991399

14001400
fn check_expr(this: &mut Liveness, expr: &Expr) {
14011401
match expr.node {
1402-
hir::ExprAssign(ref l, _) => {
1402+
hir::ExprAssign(ref l, ref r) => {
14031403
this.check_lvalue(&**l);
1404+
this.visit_expr(&**r);
14041405

14051406
visit::walk_expr(this, expr);
14061407
}

branches/tmp/src/libstd/sys/common/unwind/mod.rs

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,23 @@ pub mod imp;
9292
#[path = "gcc.rs"] #[doc(hidden)]
9393
pub mod imp;
9494

95+
pub type Callback = fn(msg: &(Any + Send), file: &'static str, line: u32);
96+
97+
// Variables used for invoking callbacks when a thread starts to unwind.
98+
//
99+
// For more information, see below.
100+
const MAX_CALLBACKS: usize = 16;
101+
static CALLBACKS: [atomic::AtomicUsize; MAX_CALLBACKS] =
102+
[atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0),
103+
atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0),
104+
atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0),
105+
atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0),
106+
atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0),
107+
atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0),
108+
atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0),
109+
atomic::AtomicUsize::new(0), atomic::AtomicUsize::new(0)];
110+
static CALLBACK_CNT: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
111+
95112
thread_local! { static PANICKING: Cell<bool> = Cell::new(false) }
96113

97114
/// Invoke a closure, capturing the cause of panic if one occurs.
@@ -229,11 +246,45 @@ pub fn begin_unwind<M: Any + Send>(msg: M, file_line: &(&'static str, u32)) -> !
229246
#[inline(never)] #[cold] // this is the slow path, please never inline this
230247
fn begin_unwind_inner(msg: Box<Any + Send>,
231248
file_line: &(&'static str, u32)) -> ! {
232-
let (file, line) = *file_line;
249+
// Make sure the default failure handler is registered before we look at the
250+
// callbacks. We also use a raw sys-based mutex here instead of a
251+
// `std::sync` one as accessing TLS can cause weird recursive problems (and
252+
// we don't need poison checking).
253+
unsafe {
254+
static LOCK: Mutex = Mutex::new();
255+
static mut INIT: bool = false;
256+
LOCK.lock();
257+
if !INIT {
258+
register(panicking::on_panic);
259+
INIT = true;
260+
}
261+
LOCK.unlock();
262+
}
233263

234-
// First, invoke the default panic handler.
235-
panicking::on_panic(&*msg, file, line);
264+
// First, invoke call the user-defined callbacks triggered on thread panic.
265+
//
266+
// By the time that we see a callback has been registered (by reading
267+
// MAX_CALLBACKS), the actual callback itself may have not been stored yet,
268+
// so we just chalk it up to a race condition and move on to the next
269+
// callback. Additionally, CALLBACK_CNT may briefly be higher than
270+
// MAX_CALLBACKS, so we're sure to clamp it as necessary.
271+
let callbacks = {
272+
let amt = CALLBACK_CNT.load(Ordering::SeqCst);
273+
&CALLBACKS[..cmp::min(amt, MAX_CALLBACKS)]
274+
};
275+
for cb in callbacks {
276+
match cb.load(Ordering::SeqCst) {
277+
0 => {}
278+
n => {
279+
let f: Callback = unsafe { mem::transmute(n) };
280+
let (file, line) = *file_line;
281+
f(&*msg, file, line);
282+
}
283+
}
284+
};
236285

286+
// Now that we've run all the necessary unwind callbacks, we actually
287+
// perform the unwinding.
237288
if panicking() {
238289
// If a thread panics while it's already unwinding then we
239290
// have limited options. Currently our preference is to
@@ -244,7 +295,34 @@ fn begin_unwind_inner(msg: Box<Any + Send>,
244295
unsafe { intrinsics::abort() }
245296
}
246297
PANICKING.with(|s| s.set(true));
247-
248-
// Finally, perform the unwinding.
249298
rust_panic(msg);
250299
}
300+
301+
/// Register a callback to be invoked when a thread unwinds.
302+
///
303+
/// This is an unsafe and experimental API which allows for an arbitrary
304+
/// callback to be invoked when a thread panics. This callback is invoked on both
305+
/// the initial unwinding and a double unwinding if one occurs. Additionally,
306+
/// the local `Thread` will be in place for the duration of the callback, and
307+
/// the callback must ensure that it remains in place once the callback returns.
308+
///
309+
/// Only a limited number of callbacks can be registered, and this function
310+
/// returns whether the callback was successfully registered or not. It is not
311+
/// currently possible to unregister a callback once it has been registered.
312+
pub unsafe fn register(f: Callback) -> bool {
313+
match CALLBACK_CNT.fetch_add(1, Ordering::SeqCst) {
314+
// The invocation code has knowledge of this window where the count has
315+
// been incremented, but the callback has not been stored. We're
316+
// guaranteed that the slot we're storing into is 0.
317+
n if n < MAX_CALLBACKS => {
318+
let prev = CALLBACKS[n].swap(mem::transmute(f), Ordering::SeqCst);
319+
rtassert!(prev == 0);
320+
true
321+
}
322+
// If we accidentally bumped the count too high, pull it back.
323+
_ => {
324+
CALLBACK_CNT.store(MAX_CALLBACKS, Ordering::SeqCst);
325+
false
326+
}
327+
}
328+
}

branches/tmp/src/test/compile-fail/issue-22599.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

branches/tmp/src/test/run-make/tools.mk

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ ifeq ($(UNAME),Bitrig)
8585
else
8686
ifeq ($(UNAME),OpenBSD)
8787
EXTRACFLAGS := -lm -lpthread
88-
# extend search lib for found estdc++ if build using gcc from
89-
# ports under OpenBSD. This is needed for:
90-
# - run-make/execution-engine
91-
# - run-make/issue-19371
92-
RUSTC := $(RUSTC) -L/usr/local/lib
9388
else
9489
EXTRACFLAGS := -lm -lrt -ldl -lpthread
9590
EXTRACXXFLAGS := -lstdc++

0 commit comments

Comments
 (0)