From 7c653c518230e2056f54dac3555a7d8ff822cfce Mon Sep 17 00:00:00 2001 From: Wildan M Date: Fri, 15 May 2026 22:46:03 +0700 Subject: [PATCH] Possible fix to race condition to EBADF --- src/context/memory.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/context/memory.rs b/src/context/memory.rs index ef1f0cee7a..686db84d10 100644 --- a/src/context/memory.rs +++ b/src/context/memory.rs @@ -71,8 +71,11 @@ impl UnmapResult { return Ok(()); }; + /// TODO: This is not ideal, the lock must be held until try_close(), however that would break borrowing rules. + /// Proper unmap operation would be a recursive operation, since closing a file can trigger another unmap(). + /// We should refactor Result of munmap() to handle unmap and closing files recursively. let (scheme_id, number) = { - let desc = description.read(token.token()); + let desc = description.write(token.token()); (desc.scheme, desc.number) };