Skip to content

native::start does not join all spawned tasks #11309

Closed
@huonw

Description

@huonw

As demonstrated by the following program, which only prints hi at the mercy of the OS scheduler (taking the 10_000 to 0 makes it never print, and making it large makes it always print, as one would expect).

#[feature(asm)];

extern mod native;

#[start]
fn start(argc: int, argv: **u8) -> int {
    native::start(argc, argv, proc() {
            spawn(proc() println("hi"));

            for _ in range(0, 10_000) { unsafe {asm!("")} }
        });
    0
}
$ rustc -O native-spawn.rs
$ for i in {0..10}; do echo $i $(./native-spawn); done
0
1
2
3
4 hi
5 hi
6 hi
7 hi
8
9 hi
10 hi

Replacing libnative with libgreen prints every time, even with no busy loop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions