Skip to content

Commit 991cbfe

Browse files
committed
Revert "rt: Call the Rust box annihilator; stop calling the cycle collector" due to crashes
This reverts commit bb0ad11.
1 parent bb0ad11 commit 991cbfe

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/rt/rust.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ command_line_args : public kernel_owned<command_line_args>
7272
// FIXME (#2670): This belongs somewhere else
7373
int check_claims = 0;
7474

75-
void* global_crate_map = NULL;
76-
7775
/**
7876
The runtime entrypoint. The (C ABI) main function generated by rustc calls
7977
`rust_start`, providing the address of the Rust ABI main function, the
@@ -88,8 +86,6 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
8886
// line as well.
8987
rust_env *env = load_env();
9088

91-
global_crate_map = crate_map;
92-
9389
update_gc_metadata(crate_map);
9490

9591
update_log_settings(crate_map, env->logspec);

src/rt/rust_globals.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,4 @@ static size_t const BUF_BYTES = 2048;
101101
// (writing), a port (reading) or a task (waiting).
102102
struct rust_cond { };
103103

104-
extern void* global_crate_map;
105-
106104
#endif /* RUST_GLOBALS_H */

src/rt/rust_task.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include "rust_cc.h"
1010
#include "rust_env.h"
1111
#include "rust_port.h"
12-
#include "rust_globals.h"
13-
#include "rust_crate_map.h"
1412

1513
// Tasks
1614
rust_task::rust_task(rust_sched_loop *sched_loop, rust_task_state state,
@@ -127,9 +125,18 @@ cleanup_task(cleanup_args *args) {
127125
main_task_failed_without_spawning = true;
128126
}
129127

130-
// Call the box annihilator.
131-
cratemap* map = reinterpret_cast<cratemap*>(global_crate_map);
132-
task->call_on_rust_stack(NULL, const_cast<void*>(map->annihilate_fn()));
128+
// FIXME (#2676): For performance we should do the annihilator
129+
// instead of the cycle collector even under normal termination, but
130+
// since that would hide memory management errors (like not derefing
131+
// boxes), it needs to be disableable in debug builds.
132+
if (threw_exception) {
133+
// FIXME (#2676): When the annihilator is more powerful and
134+
// successfully runs resource destructors, etc. we can get rid
135+
// of this cc
136+
cc::do_cc(task);
137+
annihilate_boxes(task);
138+
}
139+
cc::do_final_cc(task);
133140

134141
task->die();
135142

0 commit comments

Comments
 (0)