[UDFS] Use LONG for reference/counter fields to eliminate Interlocked casts and fix mixed sign-type comparisons#114
Closed
Copilot wants to merge 3 commits into
Closed
Conversation
Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [UDFS] Simplify usage of Interlocked functions
[UDFS] Simplify Interlocked function usage by using LONG field types
Mar 12, 2026
…ter fields to LONG Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copilot
AI
changed the title
[UDFS] Simplify Interlocked function usage by using LONG field types
[UDFS] Use LONG for reference/counter fields to eliminate Interlocked casts and fix mixed sign-type comparisons
Mar 12, 2026
Copilot AI
added a commit
that referenced
this pull request
Mar 12, 2026
…move Interlocked casts Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copilot AI
added a commit
that referenced
this pull request
Apr 16, 2026
…terlocked casts Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Counter and reference fields in the UDFS driver were declared as
ULONG/uint32despite being used exclusively with signed Interlocked operations, requiring pervasive(PLONG)/(int32*)casts at every call site. More critically, companion fields (FcbCleanup,VcbResidualReference, etc.) remainedULONGwhile their siblings were already signed, producing mixed signed/unsigned comparisons.Field type changes
struct.h— changedULONG/uint32→LONG:FcbReference,FcbCleanup,CachedOpenHandleCount,FcbUserReferenceVcbReference,VcbCleanup,VcbUserReference,VcbResidualReference,VcbResidualUserReferenceModified,numFiles,numDirs,CcbCountudf_info/udf_rel.h— changeduint32→LONG:UDF_FILE_INFO::RefCount,OpenCountUDF_DATALOC_INFO::LinkRefCountCast removal
With correct field types, all
(PLONG)/(int32*)casts are removed from ~60InterlockedIncrement/InterlockedDecrement/InterlockedExchangeAddcall sites across 9 files.Bug fix: mixed signed/unsigned comparisons
Mismatched types between
LONGreference fields and theirULONGcompanions caused implicit sign-to-unsigned conversions in comparisons. A negative value (indicating an over-release bug) would silently appear as a large positive number and pass assertions:FcbCleanup <= (FcbReference - 1)ULONG <= LONGLONG <= LONG✅VcbReference -= VcbResidualReferenceLONG -= ULONGLONG -= LONG✅VcbReference <= VcbResidualReferenceLONG <= ULONGLONG <= LONG✅Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.