Not null terminated file

Hi guys,
depending on your patch idea I wrote a small (fast and dirty) workaround until the problem is solved.

— D:\Datenkrake\llvm_14_06_02\MemoryBuffer.cpp 2014-06-02 06:34:10.000000000 ±0200
+++ D:\Datenkrake\llvm_14_06_02\lib\Support\MemoryBuffer.cpp 2014-06-02 09:41:57.000000000 ±0200
@@ -192,13 +192,20 @@
MemoryBufferMMapFile(bool RequiresNullTerminator, int FD, uint64_t Len,
uint64_t Offset, error_code EC)
: MFR(FD, false, sys::fs::mapped_file_region::readonly,
getLegalMapSize(Len, Offset), getLegalMapOffset(Offset), EC) {
if (!EC) {
const char *Start = getStart(Len, Offset);

  • init(Start, Start + Len, RequiresNullTerminator);
  • if (RequiresNullTerminator && ((Start + Len)[0] != 0))
  • {
  • EC.assign(42, system_category());
  • }
  • else
  • {
  • init(Start, Start + Len, RequiresNullTerminator);
  • }

const char *getBufferIdentifier() const override {
// The name is stored after the class itself.
return reinterpret_cast<const char *>(this + 1);

On the one hand I don’t know how EC is actually working. How to make it right?
On the other hand I also don’t know if this patch will lead to problems.

The reason why I just changed EC is that in getOpenFileImpl on the place where is checked shouldUseMmap is checked after the mmap stuff if EC is non-zero.

In my testruns this patch solves the problem with the non-zero buffer end but I receive a new failed assertion:

File: d:/Datenkrake/llvm_14_06_02/tools/clang/lib/Basic/SourceManager.cpp, Line 592
Expression: NextLocalOffset + FileSize + 1 > NextLocalOffset && NextLocalOffset + FileSize + 1 <= CurrentLoadedOffset && “Ran out of source locations!”

This assertion fails usually after the error message “modified since it was first processed”.
Is this because of my patch that he not cleanup properly or is it just another error in IBMs MVFS


PS: sry Rafael the first version of this mail was sent just to you.