Skip to content

remove solaris implementation for File::lock, it has the wrong semantics#157509

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
RalfJung:solaris-file-locks
Jun 7, 2026
Merged

remove solaris implementation for File::lock, it has the wrong semantics#157509
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
RalfJung:solaris-file-locks

Conversation

@RalfJung

@RalfJung RalfJung commented Jun 5, 2026

Copy link
Copy Markdown
Member

Fixes #157390
r? @the8472

@rustbot

rustbot commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

The Miri subtree was changed

cc @rust-lang/miri

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 5, 2026
@RalfJung RalfJung added the relnotes Marks issues that should be documented in the release notes of the next release. label Jun 5, 2026
@the8472

the8472 commented Jun 5, 2026

Copy link
Copy Markdown
Member

Uhh, wait... I previously misread the CFGs... I thought freebsd was also on the unsupported list. Because their manpage is pretty similar to Solaris.

https://man.freebsd.org/cgi/man.cgi?query=flock&sektion=2

NOTES
Locks are on files, not file descriptors.

And it mostly talks about processes owning the lock.

Even macos 😩: https://man.freebsd.org/cgi/man.cgi?query=flock&apropos=0&sektion=2&manpath=macOS+26.4

Considering that is a tier1 target I guess we have to relax the documentation instead.

@RalfJung

RalfJung commented Jun 6, 2026

Copy link
Copy Markdown
Member Author

Reading that FreeBSD manpage further, it says

That is, file descriptors
duplicated through dup(2) or fork(2) do not result in multiple in-
stances of a lock, but rather multiple references to a single lock.

That sounds like locks are on file descriptions, not file descriptors. That's quite reasonable and entirely consistent with Linux and our docs.

Also note that we have a test which ensures that locks are not per-process:

fn file_lock_blocking() {
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_lock_blocking_test.txt");
let f1 = check!(File::create(filename));
let f2 = check!(OpenOptions::new().write(true).open(filename));
// Check that shared locks block exclusive locks
check!(f1.lock_shared());
assert_matches!(f2.try_lock(), Err(TryLockError::WouldBlock));
check!(f1.unlock());
// Check that exclusive locks block shared locks
check!(f1.lock());
assert_matches!(f2.try_lock_shared(), Err(TryLockError::WouldBlock));
}

This test would have failed on Solaris. It apparently passes on macOS. So I think macOS is also doing the sane thing here.

@the8472

the8472 commented Jun 6, 2026

Copy link
Copy Markdown
Member

Hrm, ok, then the manpages are just written in a confusing manner... I guess they mean file description, not files.

@bors r+

@rust-bors

rust-bors Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 353aa6d has been approved by the8472

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 6, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 6, 2026
…8472

remove solaris implementation for File::lock, it has the wrong semantics

Fixes rust-lang#157390
r? @the8472
rust-bors Bot pushed a commit that referenced this pull request Jun 6, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #157016 (add `extern "tail"` calling convention)
 - #157264 (diagnostics: Fix ICE building a trait ref in method suggestions)
 - #157488 (compiletest: inject `#![windows_subsystem = "windows"]` to debuginfo tests on Windows)
 - #157509 (remove solaris implementation for File::lock, it has the wrong semantics)
 - #157521 (Rename `SyncView::{as_pin => as_pin_ref}`)
 - #156136 (Move tests box)
 - #157289 (Add infallible primitive type lookups to template arg resolver)
 - #157365 (Revert "LLVM 23: Run AssignGUIDPass in some places")
 - #157494 (Convert `QueryRegionConstraint` into a struct)
 - #157526 (std tests: skip a slow test on Miri)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 6, 2026
…8472

remove solaris implementation for File::lock, it has the wrong semantics

Fixes rust-lang#157390
r? @the8472
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 6, 2026
…8472

remove solaris implementation for File::lock, it has the wrong semantics

Fixes rust-lang#157390
r? @the8472
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 6, 2026
…8472

remove solaris implementation for File::lock, it has the wrong semantics

Fixes rust-lang#157390
r? @the8472
rust-bors Bot pushed a commit that referenced this pull request Jun 6, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #157251 (`rust-analyzer` subtree update)
 - #157533 (Subtree sync for rustc_codegen_cranelift)
 - #154742 (Add APIs for case folding to the standard library)
 - #155144 (mir_build: Add an extra intermediate step in MIR building for patterns )
 - #157016 (add `extern "tail"` calling convention)
 - #157264 (diagnostics: Fix ICE building a trait ref in method suggestions)
 - #157386 (Parse deprecated note links separately in rustc_resolve)
 - #157483 (fix windows-gnu TLS leak)
 - #157488 (compiletest: inject `#![windows_subsystem = "windows"]` to debuginfo tests on Windows)
 - #157509 (remove solaris implementation for File::lock, it has the wrong semantics)
 - #157521 (Rename `SyncView::{as_pin => as_pin_ref}`)
 - #156136 (Move tests box)
 - #157365 (Revert "LLVM 23: Run AssignGUIDPass in some places")
 - #157471 (Debug assert that parsed attributes are in the `BUILTIN_ATTRIBUTE_MAP`)
 - #157485 (Rename `errors.rs` file to `diagnostics.rs` (1/N))
 - #157494 (Convert `QueryRegionConstraint` into a struct)
 - #157526 (std tests: skip a slow test on Miri)

Failed merges:

 - #155527 (Replace printables table with `unicode_data.rs` tables)
rust-bors Bot pushed a commit that referenced this pull request Jun 6, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #157251 (`rust-analyzer` subtree update)
 - #157533 (Subtree sync for rustc_codegen_cranelift)
 - #154742 (Add APIs for case folding to the standard library)
 - #155144 (mir_build: Add an extra intermediate step in MIR building for patterns )
 - #157016 (add `extern "tail"` calling convention)
 - #157264 (diagnostics: Fix ICE building a trait ref in method suggestions)
 - #157386 (Parse deprecated note links separately in rustc_resolve)
 - #157483 (fix windows-gnu TLS leak)
 - #157488 (compiletest: inject `#![windows_subsystem = "windows"]` to debuginfo tests on Windows)
 - #157509 (remove solaris implementation for File::lock, it has the wrong semantics)
 - #157521 (Rename `SyncView::{as_pin => as_pin_ref}`)
 - #156136 (Move tests box)
 - #157365 (Revert "LLVM 23: Run AssignGUIDPass in some places")
 - #157471 (Debug assert that parsed attributes are in the `BUILTIN_ATTRIBUTE_MAP`)
 - #157485 (Rename `errors.rs` file to `diagnostics.rs` (1/N))
 - #157494 (Convert `QueryRegionConstraint` into a struct)
 - #157526 (std tests: skip a slow test on Miri)

Failed merges:

 - #155527 (Replace printables table with `unicode_data.rs` tables)
rust-bors Bot pushed a commit that referenced this pull request Jun 6, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #157251 (`rust-analyzer` subtree update)
 - #157533 (Subtree sync for rustc_codegen_cranelift)
 - #154742 (Add APIs for case folding to the standard library)
 - #155144 (mir_build: Add an extra intermediate step in MIR building for patterns )
 - #157016 (add `extern "tail"` calling convention)
 - #157264 (diagnostics: Fix ICE building a trait ref in method suggestions)
 - #157386 (Parse deprecated note links separately in rustc_resolve)
 - #157483 (fix windows-gnu TLS leak)
 - #157488 (compiletest: inject `#![windows_subsystem = "windows"]` to debuginfo tests on Windows)
 - #157509 (remove solaris implementation for File::lock, it has the wrong semantics)
 - #157521 (Rename `SyncView::{as_pin => as_pin_ref}`)
 - #156136 (Move tests box)
 - #157365 (Revert "LLVM 23: Run AssignGUIDPass in some places")
 - #157471 (Debug assert that parsed attributes are in the `BUILTIN_ATTRIBUTE_MAP`)
 - #157485 (Rename `errors.rs` file to `diagnostics.rs` (1/N))
 - #157494 (Convert `QueryRegionConstraint` into a struct)
 - #157526 (std tests: skip a slow test on Miri)

Failed merges:

 - #155527 (Replace printables table with `unicode_data.rs` tables)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 7, 2026
…8472

remove solaris implementation for File::lock, it has the wrong semantics

Fixes rust-lang#157390
r? @the8472
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 7, 2026
…8472

remove solaris implementation for File::lock, it has the wrong semantics

Fixes rust-lang#157390
r? @the8472
rust-bors Bot pushed a commit that referenced this pull request Jun 7, 2026
Rollup of 25 pull requests

Successful merges:

 - #157251 (`rust-analyzer` subtree update)
 - #157533 (Subtree sync for rustc_codegen_cranelift)
 - #154742 (Add APIs for case folding to the standard library)
 - #155144 (mir_build: Add an extra intermediate step in MIR building for patterns )
 - #156222 (Stabilize `Result::map_or_default` and `Option::map_or_default`)
 - #157016 (add `extern "tail"` calling convention)
 - #157264 (diagnostics: Fix ICE building a trait ref in method suggestions)
 - #157386 (Parse deprecated note links separately in rustc_resolve)
 - #157483 (fix windows-gnu TLS leak)
 - #157488 (compiletest: inject `#![windows_subsystem = "windows"]` to debuginfo tests on Windows)
 - #157509 (remove solaris implementation for File::lock, it has the wrong semantics)
 - #157521 (Rename `SyncView::{as_pin => as_pin_ref}`)
 - #156136 (Move tests box)
 - #156573 (Add unwinder_private_data_size for wasm64 target)
 - #156783 (docs: make `Rc::into_raw` clickable in `Rc::increment_strong_count` doc)
 - #156840 (Stabilize `PathBuf::into_string`)
 - #156936 (Remove FIXME about impl PinCoerceUnsized for UnsafePinned<T>)
 - #157365 (Revert "LLVM 23: Run AssignGUIDPass in some places")
 - #157380 (clarify compiler_fence (and fence) docs)
 - #157471 (Debug assert that parsed attributes are in the `BUILTIN_ATTRIBUTE_MAP`)
 - #157485 (Rename `errors.rs` file to `diagnostics.rs` (1/N))
 - #157494 (Convert `QueryRegionConstraint` into a struct)
 - #157526 (std tests: skip a slow test on Miri)
 - #157531 (ci: bump x86_64-gnu base image to 26.04)
 - #157556 (Add `BTree::append()` change to 1.96.0 relnotes)

Failed merges:

 - #155527 (Replace printables table with `unicode_data.rs` tables)
@rust-bors rust-bors Bot merged commit e828638 into rust-lang:main Jun 7, 2026
12 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 7, 2026
rust-timer added a commit that referenced this pull request Jun 7, 2026
Rollup merge of #157509 - RalfJung:solaris-file-locks, r=the8472

remove solaris implementation for File::lock, it has the wrong semantics

Fixes #157390
r? @the8472
@RalfJung RalfJung deleted the solaris-file-locks branch June 7, 2026 09:30
pull Bot pushed a commit to asukaminato0721/rust-analyzer that referenced this pull request Jun 7, 2026
Rollup of 25 pull requests

Successful merges:

 - rust-lang/rust#157251 (`rust-analyzer` subtree update)
 - rust-lang/rust#157533 (Subtree sync for rustc_codegen_cranelift)
 - rust-lang/rust#154742 (Add APIs for case folding to the standard library)
 - rust-lang/rust#155144 (mir_build: Add an extra intermediate step in MIR building for patterns )
 - rust-lang/rust#156222 (Stabilize `Result::map_or_default` and `Option::map_or_default`)
 - rust-lang/rust#157016 (add `extern "tail"` calling convention)
 - rust-lang/rust#157264 (diagnostics: Fix ICE building a trait ref in method suggestions)
 - rust-lang/rust#157386 (Parse deprecated note links separately in rustc_resolve)
 - rust-lang/rust#157483 (fix windows-gnu TLS leak)
 - rust-lang/rust#157488 (compiletest: inject `#![windows_subsystem = "windows"]` to debuginfo tests on Windows)
 - rust-lang/rust#157509 (remove solaris implementation for File::lock, it has the wrong semantics)
 - rust-lang/rust#157521 (Rename `SyncView::{as_pin => as_pin_ref}`)
 - rust-lang/rust#156136 (Move tests box)
 - rust-lang/rust#156573 (Add unwinder_private_data_size for wasm64 target)
 - rust-lang/rust#156783 (docs: make `Rc::into_raw` clickable in `Rc::increment_strong_count` doc)
 - rust-lang/rust#156840 (Stabilize `PathBuf::into_string`)
 - rust-lang/rust#156936 (Remove FIXME about impl PinCoerceUnsized for UnsafePinned<T>)
 - rust-lang/rust#157365 (Revert "LLVM 23: Run AssignGUIDPass in some places")
 - rust-lang/rust#157380 (clarify compiler_fence (and fence) docs)
 - rust-lang/rust#157471 (Debug assert that parsed attributes are in the `BUILTIN_ATTRIBUTE_MAP`)
 - rust-lang/rust#157485 (Rename `errors.rs` file to `diagnostics.rs` (1/N))
 - rust-lang/rust#157494 (Convert `QueryRegionConstraint` into a struct)
 - rust-lang/rust#157526 (std tests: skip a slow test on Miri)
 - rust-lang/rust#157531 (ci: bump x86_64-gnu base image to 26.04)
 - rust-lang/rust#157556 (Add `BTree::append()` change to 1.96.0 relnotes)

Failed merges:

 - rust-lang/rust#155527 (Replace printables table with `unicode_data.rs` tables)
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Jun 8, 2026
Rollup of 25 pull requests

Successful merges:

 - rust-lang/rust#157251 (`rust-analyzer` subtree update)
 - rust-lang/rust#157533 (Subtree sync for rustc_codegen_cranelift)
 - rust-lang/rust#154742 (Add APIs for case folding to the standard library)
 - rust-lang/rust#155144 (mir_build: Add an extra intermediate step in MIR building for patterns )
 - rust-lang/rust#156222 (Stabilize `Result::map_or_default` and `Option::map_or_default`)
 - rust-lang/rust#157016 (add `extern "tail"` calling convention)
 - rust-lang/rust#157264 (diagnostics: Fix ICE building a trait ref in method suggestions)
 - rust-lang/rust#157386 (Parse deprecated note links separately in rustc_resolve)
 - rust-lang/rust#157483 (fix windows-gnu TLS leak)
 - rust-lang/rust#157488 (compiletest: inject `#![windows_subsystem = "windows"]` to debuginfo tests on Windows)
 - rust-lang/rust#157509 (remove solaris implementation for File::lock, it has the wrong semantics)
 - rust-lang/rust#157521 (Rename `SyncView::{as_pin => as_pin_ref}`)
 - rust-lang/rust#156136 (Move tests box)
 - rust-lang/rust#156573 (Add unwinder_private_data_size for wasm64 target)
 - rust-lang/rust#156783 (docs: make `Rc::into_raw` clickable in `Rc::increment_strong_count` doc)
 - rust-lang/rust#156840 (Stabilize `PathBuf::into_string`)
 - rust-lang/rust#156936 (Remove FIXME about impl PinCoerceUnsized for UnsafePinned<T>)
 - rust-lang/rust#157365 (Revert "LLVM 23: Run AssignGUIDPass in some places")
 - rust-lang/rust#157380 (clarify compiler_fence (and fence) docs)
 - rust-lang/rust#157471 (Debug assert that parsed attributes are in the `BUILTIN_ATTRIBUTE_MAP`)
 - rust-lang/rust#157485 (Rename `errors.rs` file to `diagnostics.rs` (1/N))
 - rust-lang/rust#157494 (Convert `QueryRegionConstraint` into a struct)
 - rust-lang/rust#157526 (std tests: skip a slow test on Miri)
 - rust-lang/rust#157531 (ci: bump x86_64-gnu base image to 26.04)
 - rust-lang/rust#157556 (Add `BTree::append()` change to 1.96.0 relnotes)

Failed merges:

 - rust-lang/rust#155527 (Replace printables table with `unicode_data.rs` tables)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File::lock (probably) behaves incorrectly on Solaris

3 participants