[clang] [clang][deps] Call getMemBuffer with RequiresNullTerminator false (PR #194867)
Peter Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 29 07:04:33 PDT 2026
https://github.com/smithp35 created https://github.com/llvm/llvm-project/pull/194867
The getMemBuffer() has a default parameter RequiresNullTerminator which is set to true.
In ModuleCache the MemoryBuffer::getOpenFile is called with /* RequiresNullTerminator=*/false.
We have at one build with assertions enabled that is tripping over an assertion in MemoryBuffer that is checking for null termination. This failure is currently specific to this single machine and all attempts to reproduce have failed.
My working theory is that the length of path names are important so on most machines we may be adding trailing 0x0 bytes of padding which are being counted as null terminators.
Patch is in a draft state to see if we can tell if this fixes the problem.
>From 20fda6b74e58fa2cf48108ec639b64bdf9852822 Mon Sep 17 00:00:00 2001
From: Peter Smith <peter.smith at arm.com>
Date: Wed, 29 Apr 2026 11:41:17 +0100
Subject: [PATCH] [clang][deps] Call getMemBuffer with RequiresNullTerminator
false
The getMemBuffer() has a default parameter RequiresNullTerminator
which is set to true.
In ModuleCache the MemoryBuffer::getOpenFile is called with
/* RequiresNullTerminator=*/false.
We have at one build with assertions enabled that is tripping
over an assertion in MemoryBuffer that is checking for null
termination. This failure is currently specific to this single
machine and all attempts to reproduce have failed.
My working theory is that the length of path names are important
so on most machines we may be adding trailing 0x0 bytes of padding
which are being counted as null terminators.
Patch is in a draft state to see if we can tell if this fixes
the problem.
---
clang/lib/DependencyScanning/InProcessModuleCache.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/clang/lib/DependencyScanning/InProcessModuleCache.cpp b/clang/lib/DependencyScanning/InProcessModuleCache.cpp
index 0e2286c18e902..d197bc8218a77 100644
--- a/clang/lib/DependencyScanning/InProcessModuleCache.cpp
+++ b/clang/lib/DependencyScanning/InProcessModuleCache.cpp
@@ -178,7 +178,8 @@ class InProcessModuleCache : public ModuleCache {
}
Size = Entry.Buffer->getBufferSize();
ModTime = Entry.ModTime;
- return llvm::MemoryBuffer::getMemBuffer(*Entry.Buffer);
+ return llvm::MemoryBuffer::getMemBuffer(*Entry.Buffer,
+ /* RequiresNullTerminator */ false);
}
};
} // namespace
More information about the cfe-commits
mailing list