[cfe-dev] Not null terminated file

tsett tsett at gmx.net
Mon Jun 16 01:19:41 PDT 2014


Hello again,
Looks like no one has a clue :( 

Can then someone please tell me where this warning is coming from?
Also I try to understand the assertion.
What does she means exactly?

Best,
Robert

Von Samsung Mobile gesendet

-------- Ursprüngliche Nachricht --------
Von: Robert Zimmermann <tsett at gmx.net> 
Datum:06.06.2014  14:43  (GMT+01:00) 
An: cfe-dev at cs.uiuc.edu 
Betreff: Re: [cfe-dev] 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
 
Best,
Robert
 
PS: sry Rafael the first version of this mail was sent just to you.
 
Gesendet: Mittwoch, 28. Mai 2014 um 07:07 Uhr
Von: "Rafael Espíndola" <rafael.espindola at gmail.com>
An: tsett <tsett at gmx.net>
Cc: "clang-dev Developers" <cfe-dev at cs.uiuc.edu>
Betreff: Re: [cfe-dev] Not null terminated file
On 27 May 2014 15:54, tsett <tsett at gmx.net> wrote:
> This sounds good to me. Especially for the check of the last byte.
> Should I report my issue there too?

I think the bug covers it, no?

If you have more information you want to add to the bug, pleas do.

Cheers,
Rafael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140616/7c29d1c9/attachment.html>


More information about the cfe-dev mailing list