Closed Bug 1659904 Opened 5 years ago Closed 5 years ago

UnixFile.open should be defined as variadic

Categories

(Toolkit Graveyard :: OS.File, defect)

defect

Tracking

(firefox81 fixed)

RESOLVED FIXED
81 Branch
Tracking Status
firefox81 --- fixed

People

(Reporter: glandium, Assigned: glandium)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

The definition of the function is variadic like the following on at least Linux and OSX:
int open(const char *, int, ...)

We're lucky that things are lined up in a way where it just works on all our current platforms, but it falls short on Apple Silicon macs because the ABI in that case is that the mode needs to end up on the stack which it doesn't if the function is not defined as variadic on the ctypes side.

Fortunately, variadic functions are supported by ctypes, although that's not documented. See https://bugzilla.mozilla.org/show_bug.cgi?id=554790#c22.

Additional complication, though: ctypes doesn't actually implement variadic functions correctly. Will file a seperate bug for the ctypes side of things.

Oh, I should mention, the result of this problem is that files opened with O_CREAT end up with garbage permissions, and we're lucky if they're readable at all after that.

Depends on: 1659905

That is how it is actually defined in fcntl.h, and thus how C code calls
it. It so happens that in many cases, it just works out fine because
variadic arguments end up at the same place as if they weren't variadic
in registers/stack, but that's not actually true on all platforms. Most
notably, that's not true on Apple Silicon.

Pushed by mh@glandium.org: https://hg.mozilla.org/integration/autoland/rev/2cb7fc096723 Define UnixFile.open as a variadic function. r=Yoric
Backout by csabou@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e8d3ae8df154 Backed out changeset 2cb7fc096723 for mochitest failures on test_osfile_back.xhtml. CLOSED TREE
Pushed by mh@glandium.org: https://hg.mozilla.org/integration/autoland/rev/891217d9ac80 Define UnixFile.open as a variadic function. r=Yoric
Flags: needinfo?(mh+mozilla)
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: