Skip to content

Deadlocks on NetBSD around fork() #76600

Closed
@he32

Description

@he32

I do realize this is likely to be ignored, but I just cannot let go of bringing it up anyway...

It appears to me that rust in certain circumstances is relying on undefined behavior, in that it is in general a multi-threaded program, and will in many cases do fork(), and perform many non-trivial tasks between fork() and exec(). Some of these things have manifested themselves in run-time problems observed on NetBSD: (detected) deadlocks in ld.elf_so (resulting in abort), deadlocks related to malloc() manifesting as hangs etc. In NetBSD, the fork() man page contains this passage:

     Child processes of a threaded program have additional restrictions, a
     child must only call functions that are async-signal-safe.  Very few
     functions are asynchronously safe (the list may be found in sigaction(2))
     and applications should make sure they call exec(3) as soon as possible.

A Linux/Debian man page for fork(2) also contains a similar passage:

       *  After a fork() in a multithreaded program, the child can safely call
          only async-signal-safe functions (see signal-safety(7))  until  such
          time as it calls execve(2).

Even though I don't point to offending code here, I have it on good authority that this is the root cause of the issues we have been observing on NetBSD. Is there any chance that the rust code could have a make-over so as to not rely on undefined behavior in this aspect?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-netbsdOperating system: NetBSDT-libsRelevant to the library 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