Skip to content

Weirdness (bug) in kernel function jl_new_task #36361

@fingolfin

Description

@fingolfin

In src/task.c, function jl_new_task does the following:

...
    if (ssize == 0) {
        ...
    }
    else {
        // user requested dedicated stack of a certain size
        if (ssize < MINSTKSZ)
            ssize = MINSTKSZ;
        t->bufsz = ssize;
        t->stkbuf = jl_alloc_fiber(&t->ctx, &t->bufsz, t);
        if (t->stkbuf == NULL)
            jl_throw(jl_memory_exception);
    }
...
    t->stkbuf = NULL;

So if ssize != 0 then t->stkbuf is allocated and care is taken to ensure it's non-zero, but then later it gets zeroed out unconditionally (no return or conditional statement statement comes in between, so I really think this is what happens).

This looks like a bug, presumably t->stkbuf. Even if it is intentional, then I'd think the first use of t->stkbuf inside the else {...} block should be rather replaced by a local variable, and a comment should be added why this makes sense.

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