Skip to content

Comments

Update memcall_windows.go#15

Open
jgowdy-godaddy wants to merge 1 commit intoawnumar:masterfrom
jgowdy-godaddy:patch-1
Open

Update memcall_windows.go#15
jgowdy-godaddy wants to merge 1 commit intoawnumar:masterfrom
jgowdy-godaddy:patch-1

Conversation

@jgowdy-godaddy
Copy link

Normalize the behavior of unlocking a region that is not locked which causes an error on Windows and succeeds on POSIX operating systems. This avoids panics that happen on Windows that don't happen on POSIX operating systems:

panicked: could not free lock on 0x19e748b1000 [Err: The segment is already unlocked.]

Normalize the behavior of unlocking a region that is not locked which causes an error on Windows and succeeds on POSIX operating systems.
@awnumar
Copy link
Owner

awnumar commented Mar 2, 2025

Are you importing this library directly or via another package?

What situation leads to freeing a lock on an unlocked region of memory?

@jgowdy-godaddy
Copy link
Author

We are using memguard, not using memcall directly. Our usage of memguard on Windows causes this panic, whereas usage on macOS and Linux does not. There are differences in how Linux and Windows tracks locks on overlapping regions, and differences in how the calls respond to unlocking a region that is not locked. I wouldn't expect there's anything we could be doing through the memguard interface to trigger this issue specifically based on usage. In the end, the differences in locking and unlocking behavior make trying to track this down for the Windows use case seem quixotic. That's why I'm suggesting just normalizing the VirtualUnlock behavior to the munlock behavior as much as possible.

image

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.

2 participants