[obsolete] Fix crashes on indexing -> replaced by MR 360#351
Open
caco3 wants to merge 1 commit intozevv:v1.5.0-rc2from
Open
[obsolete] Fix crashes on indexing -> replaced by MR 360#351caco3 wants to merge 1 commit intozevv:v1.5.0-rc2from
caco3 wants to merge 1 commit intozevv:v1.5.0-rc2from
Conversation
Indexing large directories (15,000+ files) Using GUI hover tooltips Processing many large files (25+ files) This commit fixes it
7 tasks
l8gravely
reviewed
Apr 3, 2026
Collaborator
There was a problem hiding this comment.
This chunk being commented out isn't what I'd like to do, rather let's fix any crash happening here. When you comment something out, please say why you did so and point to an example.
l8gravely
reviewed
Apr 3, 2026
l8gravely
reviewed
Apr 3, 2026
Collaborator
There was a problem hiding this comment.
All these option parsing should be handled in a function which has proper error reporting. Just because someone passes in too many options and causes a string overflow, we shouldn't crash without exiting cleanly with an error here. Or at least warning that this option was skipped because we ran out of space.
l8gravely
reviewed
Apr 3, 2026
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.
To be replaced by #360
Notes
Fix Memory Corruption and Buffer Overflow Issues
Problem Summary
Duc was crashing with segmentation faults and heap corruption when:
Root Causes Found and Fixed by AI
1. Critical Buffer Overflow in
buffer.c(PRIMARY FIX)File:
src/libduc/buffer.cFunction:
buffer_put()Issue: Inverted condition caused buffer overflow when buffers needed to grow
Before:
After:
Impact: This was the main cause of crashes during large directory indexing
2. Memory Management Inconsistencies
Files:
src/libduc/index.c,src/libduc/canonicalize.cIssue: Mixed use of
duc_malloc()/duc_free()with standardmalloc()/free()Fixes Applied:
free()calls toduc_free()for memory allocated withduc_malloc*()duc_index_req_free(),scanner_free(),duc_canonicalize_path()3. Database Options Buffer Overflow
File:
src/libduc/db-tkrzw.cIssue: Unchecked
strcat()operations could overflow 256-byte options bufferFix: Added bounds checking before each
strcat():4. Indexing strncpy Buffer Overflow
File:
src/libduc/index.cIssue: Used wrong buffer size in
strncpy()callBefore:
After:
5. Histogram Array Bounds Issue
File:
src/libduc/index.cIssue: Accessed histogram array even when
histogram_buckets = 0Fix: Added bounds check:
6. Buffer Loading strncpy Overflow
File:
src/libduc/buffer.cIssue:
strncpy()without proper bounds checkingFix: Added proper bounds and null termination
7. Disabled Broken TopN Array Saving
File:
src/libduc/db.cIssue: TopN array saving code was fundamentally broken (saving pointers instead of data)
Fix: Commented out with FIXME to prevent crashes
Test Results
Before Fixes
After Fixes
Files Modified
src/libduc/buffer.c- Fixed critical buffer overflow (main issue)src/libduc/index.c- Memory management, strncpy, histogram fixessrc/libduc/db-tkrzw.c- Database options buffer overflowsrc/libduc/canonicalize.c- Memory management consistencysrc/libduc/db.c- Disabled broken TopN savingImpact
This fix resolves all memory corruption issues in Duc, enabling:
The primary fix was the inverted condition in
buffer_put(), which was causing heap corruption during buffer growth operations in large-scale indexing operations.