Skip to content

Return codes of libc functions are checked for errors only in debug mode. #34966

Closed
@ghost

Description

In libstd/sys/unix there are numerous cases where return code is checked for
error using following pattern:

let result = libc::pthread_mutexattr_init(&mut attr as *mut _);
debug_assert_eq!(result, 0);

That means, that error checking is performed only when compiled in
non-optimized mode or after explicitly enabling debug assertions. This is a
little bit worrying, especially when used on platforms where those functions
can indeed fail and break safety.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.C-enhancementCategory: An issue proposing an enhancement or a PR with one.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions