@@ -731,8 +731,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) {
731
731
// Getting killed after here would leak the task.
732
732
733
733
let child_wrapper =
734
- make_child_wrapper ( new_task, child_tg,
735
- opts. supervise , is_main, f) ;
734
+ make_child_wrapper ( new_task, child_tg, is_main, f) ;
736
735
let fptr = ptr:: addr_of ( child_wrapper) ;
737
736
let closure: * rust_closure = unsafe :: reinterpret_cast ( fptr) ;
738
737
@@ -750,19 +749,14 @@ fn spawn_raw(opts: task_opts, +f: fn~()) {
750
749
}
751
750
752
751
fn make_child_wrapper ( child_task : * rust_task , -child_tg : taskgroup_arc ,
753
- supervise : bool , is_main : bool ,
754
- -f : fn ~( ) ) -> fn ~( ) {
752
+ is_main : bool , -f : fn ~( ) ) -> fn ~( ) {
755
753
let child_tg_ptr = ~mut some ( child_tg) ;
756
754
fn ~( ) {
757
755
// Agh. Get move-mode items into the closure. FIXME (#2829)
758
756
let mut child_tg_opt = none;
759
757
* child_tg_ptr <-> child_tg_opt;
760
758
let child_tg = option:: unwrap ( child_tg_opt) ;
761
759
// Child task runs this code.
762
- if !supervise {
763
- // FIXME (#1868, #1789) take this out later
764
- rustrt:: unsupervise ( ) ;
765
- }
766
760
// Set up membership in taskgroup. If this returns none, the
767
761
// parent was already failing, so don't bother doing anything.
768
762
alt enlist_in_taskgroup ( child_tg, child_task) {
@@ -1018,7 +1012,6 @@ extern mod rustrt {
1018
1012
fn start_task ( task : * rust_task , closure : * rust_closure ) ;
1019
1013
1020
1014
fn rust_task_is_unwinding ( task : * rust_task ) -> bool ;
1021
- fn unsupervise ( ) ;
1022
1015
fn rust_osmain_sched_id ( ) -> sched_id ;
1023
1016
fn rust_task_inhibit_kill ( ) ;
1024
1017
fn rust_task_allow_kill ( ) ;
@@ -1464,6 +1457,21 @@ fn test_unkillable_nested() {
1464
1457
po.recv();
1465
1458
}
1466
1459
1460
+ #[test]
1461
+ fn test_child_doesnt_ref_parent() {
1462
+ // If the child refcounts the parent task, this will stack overflow when
1463
+ // climbing the task tree to dereference each ancestor. (See #1789)
1464
+ const generations: uint = 8192;
1465
+ fn child_no(x: uint) -> fn~() {
1466
+ ret || {
1467
+ if x < generations {
1468
+ task::spawn(child_no(x+1));
1469
+ }
1470
+ }
1471
+ }
1472
+ task::spawn(child_no(0));
1473
+ }
1474
+
1467
1475
#[test]
1468
1476
fn test_tls_multitask() unsafe {
1469
1477
fn my_key(+_x: @~str) { }
0 commit comments