Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 19, 2025

This PR fixes an immediate runtime panic that occurs when using the --compare-hash=MD5 flag with sync operations on FAT32/exFAT formatted drives on Windows.

Problem

When running commands like:

azcopy sync "D:\HashingTest" $destination --put-md5 --compare-hash=MD5

On FAT32/exFAT drives, users encountered an immediate panic:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x8 pc=0x13b2d32]

goroutine 1 [running]:
github.com/Azure/azure-storage-azcopy/v10/cmd.(*localTraverser).IsDirectory(0x0?, 0x0?)

Root Cause

The issue occurred because:

  1. Hash adapter initialization failure: On Windows, AzCopy defaults to using Alternate Data Streams (ADS) for hash storage, but FAT32/exFAT filesystems don't support ADS
  2. Error swallowing: In zc_enumerator.go line 463, the error from newLocalTraverser() was being ignored using output, _ = newLocalTraverser(...)
  3. Nil pointer dereference: This resulted in a nil traverser that caused a panic when IsDirectory() was called later in the sync process

Solution

The fix is minimal and surgical - properly handle the error from newLocalTraverser() instead of ignoring it:

Before:

output, _ = newLocalTraverser(resource.ValueLocal(), ctx, opts)

After:

output, err = newLocalTraverser(resource.ValueLocal(), ctx, opts)
if err != nil {
    return nil, err
}

Impact

  • Eliminates panic: Users no longer experience runtime crashes when using hash comparison on unsupported filesystems
  • Provides clear error messages: Instead of a panic, users receive informative error messages about hash adapter initialization failures
  • Preserves existing functionality: All existing behavior remains unchanged for supported scenarios
  • Enables proper error handling: Users can now handle the error gracefully and choose alternative approaches

This change allows users to receive proper feedback about filesystem compatibility issues rather than experiencing unexpected crashes, enabling them to use alternative hash storage modes or different filesystems as needed.

Fixes #3221.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fake.blob.core.windows.net
    • Triggering command: ./azcopy/azure-storage-azcopy sync /tmp/hash_init_test_1758259955 REDACTED --compare-hash=MD5 --dry-run (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Contributor Author

Copilot AI commented Sep 19, 2025

@vibhansa-msft 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

The issue occurred because newLocalTraverser can fail when trying to initialize
the hash data adapter on filesystems that don't support the default storage mode
(like FAT32/exFAT with Alternate Data Streams on Windows). The error was being
swallowed in zc_enumerator.go line 463, causing a nil traverser that led to
a panic when IsDirectory() was called later.

This fix properly handles the error from newLocalTraverser instead of ignoring it,
preventing the nil pointer dereference and providing users with a clear error
message about hash adapter initialization failure.

Co-authored-by: vibhansa-msft <[email protected]>
Copilot AI changed the title [WIP] Immediate runtime error when using MD5 to compare hash on FAT32/exFAT formatted drives Fix nil pointer panic when using MD5 hash comparison on FAT32/exFAT drives Sep 19, 2025
Copilot AI requested a review from vibhansa-msft September 19, 2025 05:34
Copilot finished work on behalf of vibhansa-msft September 19, 2025 05:34
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.

Immediate runtime error when using MD5 to compare hash on FAT32/exFAT formatted drives

2 participants