Skip to content

Commit 3dfd7a6

Browse files
author
Elliott Slaughter
committed
---
yaml --- r: 23779 b: refs/heads/master c: 578b036 h: refs/heads/master i: 23777: 6a35a1e 23775: c4839f7 v: v3
1 parent 4bde1ff commit 3dfd7a6

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 7823ad8586f52bcd6277965277bd15ff15674219
2+
refs/heads/master: 578b036f9b0415852aae0af9286ff53630fa1c56
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/gc.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,33 @@ fn RootSet() -> RootSet {
167167
LinearMap()
168168
}
169169

170+
#[cfg(gc)]
171+
fn expect_sentinel() -> bool { true }
172+
173+
#[cfg(nogc)]
174+
fn expect_sentinel() -> bool { false }
175+
170176
// This should only be called from fail, as it will drop the roots
171177
// which are *live* on the stack, rather than dropping those that are
172178
// dead.
173179
fn cleanup_stack_for_failure() {
174180
unsafe {
175-
// Leave a sentinel on the stack to mark the current
176-
// frame. The stack walker will ignore any frames above the
177-
// sentinel, thus avoiding collecting any memory being used by
178-
// the stack walker itself.
181+
// Leave a sentinel on the stack to mark the current frame. The
182+
// stack walker will ignore any frames above the sentinel, thus
183+
// avoiding collecting any memory being used by the stack walker
184+
// itself.
185+
//
186+
// However, when core itself is not compiled with GC, then none of
187+
// the functions in core will have GC metadata, which means we
188+
// won't be able to find the sentinel root on the stack. In this
189+
// case, we can safely skip the sentinel since we won't find our
190+
// own stack roots on the stack anyway.
179191
let sentinel_box = ~0;
180-
let sentinel: **Word =
181-
unsafe::reinterpret_cast(&ptr::addr_of(sentinel_box));
192+
let sentinel: **Word = if expect_sentinel() {
193+
unsafe::reinterpret_cast(&ptr::addr_of(sentinel_box))
194+
} else {
195+
ptr::null()
196+
};
182197

183198
let mut roots = ~RootSet();
184199
for walk_gc_roots(need_cleanup, sentinel) |root, tydesc| {

0 commit comments

Comments
 (0)