Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

interrupt::free is not enough to access static mut safely #49

Closed
@jonas-schievink

Description

@jonas-schievink

At least in the presence of multiple cores sharing the same set of statics. Problematic code:

static mut HSTDOUT: Option<HStdout> = None;
pub fn hstdout_str(s: &str) -> Result<(), ()> {
interrupt::free(|_| unsafe {
if HSTDOUT.is_none() {
HSTDOUT = Some(hio::hstdout()?);
}
HSTDOUT.as_mut().unwrap().write_str(s).map_err(drop)
})
}

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