Skip to content

The go! macro is unsound #109

@jmaargh

Description

@jmaargh

The go! macro is unsound and should require an unsafe block to use, with proper "Safety" documentation for the macro.

As discussed in #6, this crate can be unsound when thread-local storage is used. My understanding is that this is an unavoidable property of stackful coroutines when there isn't language-level support for them. Nonetheless, APIs that can lead to UB should only be accessible within an unsafe block and have documentation for the conditions under which their use is sound (that's what unsafe is for).

In #8 the spawn API was correctly marked as unsafe because of this. However, then the go! macro was introduced which simply silently inserts the unsafe block -- this only serves to hide the issue from users and obscure the safety documentation.

Personally, I'd remove the go! macro altogether. But if it is to stay, then I think it should definitely require an unsafe block and its safety requirements should be properly documented as any unsafe function should.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions