[Konsole-devel] [konsole] [Bug 304148] Konsole 4.8.4 crashed in CompactHistoryLine

Ciaran Gillespie ciaran.gillespie at gmail.com
Fri Sep 6 00:11:50 UTC 2013


https://bugs.kde.org/show_bug.cgi?id=304148

--- Comment #4 from Ciaran Gillespie <ciaran.gillespie at gmail.com> ---
Ah I think I found the problem!

So in the constructor for CompactHistoryBlock it tries to use mmap and cast it
into an incremental  quint8* pointer. Now when CompactHistoryBlock tries to
iterator over the pointers that are quint8 it will do so in 8-bit steps. This
will cause a major issue for SPARCv8-9 and possibly other architectures as the
memory must be either half-word aligned (16-bit) or word (32-bit). I'm guessing
this works fine on x86_64 and i386 as 8-bit memory alignment is safe.

Here is the diff of my changes, I would like to know if this solves Matt W.'s
issue though I am unsure if this in fact the same problem we are having, if not
I will have to create a new ticket with my bug and the patch.

diff --git a/src/History.h b/src/History.h
index b4070fb..d2417df 100644
--- a/src/History.h
+++ b/src/History.h
@@ -202,7 +202,7 @@ class CompactHistoryBlock
 public:
     CompactHistoryBlock() {
         _blockLength = 4096 * 64; // 256kb
-        _head = (quint8*) mmap(0, _blockLength, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
+        _head = (quint32*) mmap(NULL, _blockLength, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
         //_head = (quint8*) malloc(_blockLength);
         Q_ASSERT(_head != MAP_FAILED);
         _tail = _blockStart = _head;
@@ -231,9 +231,9 @@ public:

 private:
     size_t _blockLength;
-    quint8* _head;
-    quint8* _tail;
-    quint8* _blockStart;
+    quint32* _head;
+    quint32* _tail;
+    quint32* _blockStart;
     int _allocCount;
 };

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the konsole-devel mailing list