- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.4k
 
FdbDecode memory issues fix #12495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release-7.4
Are you sure you want to change the base?
FdbDecode memory issues fix #12495
Conversation
          Result of foundationdb-pr-macos on macOS Ventura 13.x
  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'd also need one more approval for release branch, maybe @jzhou77 or @saintstack can do it?
          Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
  | 
    
          Result of foundationdb-pr-clang-arm on Linux CentOS 7
  | 
    
          Result of foundationdb-pr-clang on Linux RHEL 9
  | 
    
          Result of foundationdb-pr on Linux RHEL 9
  | 
    
          Result of foundationdb-pr-cluster-tests on Linux RHEL 9
  | 
    
          
 @jzhou77 macOs build is failing with the system time issue "ninja: error: manifest 'build.ninja' still dirty after 100 tries, perhaps system time is not set". Can you please adjust the time? I forgot on which sever to do.  | 
    
ad71843    to
    ec856c6      
    Compare
  
    
          Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
  | 
    
          Result of foundationdb-pr-clang-arm on Linux CentOS 7
  | 
    
          Result of foundationdb-pr-cluster-tests on Linux RHEL 9
  | 
    
          Result of foundationdb-pr-macos on macOS Ventura 13.x
  | 
    
          Result of foundationdb-pr-clang on Linux RHEL 9
  | 
    
          Result of foundationdb-pr on Linux RHEL 9
  | 
    
cherry-pick of #12456
FdbDecode memory issues fix.
The fdbdecode command was throwing memory-related errors such as:
double free or corruption (!prev), free(): invalid pointer, munmap_chunk(): invalid pointer, Segmentation fault
These errors occurred only during the program’s shutdown phase, after all decoding work was completed. They did not affect the correctness of the decoded key–value output.
Root Cause
Valgrind analysis revealed that the crashes were caused by static object destruction order issues, leading to use-after-free and double-free situations.
Issue 1: EventCacheHolder
A static EventCacheHolder instance invoked clear() during its destruction, which accessed a LatestEventCache object that had already been destroyed.
Issue 2: BlobStats
Another static variable, BlobStats, owned an EventCacheHolder instance. During shutdown, its destruction triggered the same invalid access pattern described above.