Skip to content

Conversation

@mafredri
Copy link
Member

@mafredri mafredri commented Dec 12, 2025

Rename: If unRegisterWithParent or renameDescendants returns an error,
the function returns while holding an exclusive write lock, but the
deferred RUnlock runs instead of Unlock.

RemoveAll: Unsafe modification of data map under the assumption that all
entries belong to unregistered path. This implementaiton also raced with
non-standard implicit MkdirAll behavior of Create.

@mafredri mafredri force-pushed the mafredri/memmap-fix branch from ed7f3f2 to 283a094 Compare December 12, 2025 15:07

m.registerWithParent(file, 0)
m.mu.Unlock()
m.getData()[name] = file
Copy link
Member Author

@mafredri mafredri Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Drive-by change in preparation of potential future removal of implicit MkdirAll behavior of registerWithParent.

The ordering is more explicit and avoids inconsistent state if an error path is introduced.

Rename: If unRegisterWithParent or renameDescendants returns an error,
the function returns while holding an exclusive write lock, but the
deferred RUnlock runs instead of Unlock.

RemoveAll: Unsafe modification of data map under the assumption that all
entries belong to unregistered path. This implementaiton also raced with
non-standard implicit MkdirAll behavior of Create.
@mafredri mafredri force-pushed the mafredri/memmap-fix branch from 283a094 to 0f8fdbe Compare December 12, 2025 15:12
m.registerWithParent(item, perm)
m.mu.Unlock()

return m.setFileMode(name, perm|os.ModeDir)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Dupe, mem.SetMode is already used above.

m.mu.Lock()
mem.SetModTime(f, mtime)
m.mu.Unlock()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Motivation: Consistency. We already have a reference to the file handle, and mem functions acquire f.Lock. Whether or not we're updating a stale file is irrelevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant