Summary: | Konsole 4.8.4 crashed in CompactHistoryLine | ||
---|---|---|---|
Product: | [Applications] konsole | Reporter: | Matt Whitlock <kde> |
Component: | history | Assignee: | Konsole Developer <konsole-devel> |
Status: | RESOLVED WORKSFORME | ||
Severity: | crash | CC: | andrew.crouthamel, ciaran.gillespie, cpigat242 |
Priority: | NOR | ||
Version: | 2.8.4 | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | Patch for History.h in Konsole to fix Bus Error on SPARCv8 and v9 |
Description
Matt Whitlock
2012-07-27 16:14:03 UTC
I have a similar problem with that function as well. Not sure if it's related, it on a SPARC64 system running Debian Wheezy with Konsole 4.8.4 as well. This is the back trace from the system. Program received signal SIGBUS, Bus error. 0xf7bfa928 in Konsole::CompactHistoryLine::CompactHistoryLine (this=0xf1610056, line=..., bList=...) at /home/ciaran/Documents/konsole-4.8.4/src/History.cpp:586 586 formatLength(0) (gdb) backtrace #0 0xf7bfa928 in Konsole::CompactHistoryLine::CompactHistoryLine (this=0xf1610056, line=..., bList=...) at /home/ciaran/Documents/konsole-4.8.4/src/History.cpp:586 #1 0xf7bfade8 in Konsole::CompactHistoryScroll::addCellsVector (this=0x1937c8, cells=...) at /home/ciaran/Documents/konsole-4.8.4/src/History.cpp:697 #2 0xf7c23b54 in addHistLine (this=0x18e090) at /home/ciaran/Documents/konsole-4.8.4/src/Screen.cpp:1323 #3 Konsole::Screen::addHistLine (this=0x18e090) at /home/ciaran/Documents/konsole-4.8.4/src/Screen.cpp:1314 #4 0xf7c247f0 in Konsole::Screen::scrollUp (this=0x18e090, n=1) at /home/ciaran/Documents/konsole-4.8.4/src/Screen.cpp:767 #5 0xf7bf3714 in Konsole::Emulation::receiveData (this=0x18d978, text=0x35f200 "\r\n>>> ", length=6) at /home/ciaran/Documents/konsole-4.8.4/src/Emulation.cpp:250 #6 0xf7c2bdd8 in Konsole::Session::onReceiveBlock (this=0x18d528, buf=0x35f200 "\r\n>>> ", len=6) at /home/ciaran/Documents/konsole-4.8.4/src/Session.cpp:1302 #7 0xf7c2f7c8 in qt_static_metacall (_a=0xff88266c, _id=<optimized out>, _o=0x18d528, _c=<optimized out>) at /home/ciaran/Documents/konsole-4.8.4/src/Session.moc:216 #8 Konsole::Session::qt_static_metacall (_o=0x18d528, _c=QMetaObject::InvokeMetaMethod, _id=<optimized out>, _a=0xff88266c) at /home/ciaran/Documents/konsole-4.8.4/src/Session.moc:154 #9 0xf6e53c30 in QMetaObject::activate (sender=0x18e9b0, m=<optimized out>, local_signal_index=<optimized out>, argv=0xff88266c) at kernel/qobject.cpp:3547 #10 0xf7c20568 in Konsole::Pty::receivedData (this=0x18e9b0, _t1=0x35f200 "\r\n>>> ", _t2=6) at /home/ciaran/Documents/konsole-4.8.4/src/Pty.moc:111 #11 0xf7c205b4 in Konsole::Pty::dataReceived (this=0x18e9b0) at /home/ciaran/Documents/konsole-4.8.4/src/Pty.cpp:304 #12 0xf6e53c30 in QMetaObject::activate (sender=0x16a2d0, m=<optimized out>, local_signal_index=<optimized out>, argv=0x0) at kernel/qobject.cpp:3547 #13 0xf7b748bc in KPtyDevicePrivate::_k_canRead (this=0x18efc8) at ../../kpty/kptydevice.cpp:335 #14 0xf7b74e3c in qt_static_metacall (_a=0xff882980, _o=0x16a2d0, _c=<optimized out>, _id=<optimized out>) at ./kptydevice.moc:55 #15 KPtyDevice::qt_static_metacall (_o=0x16a2d0, _c=QMetaObject::InvokeMetaMethod, _id=1, _a=0xff882980) at ./kptydevice.moc:48 #16 0xf6e53c30 in QMetaObject::activate (sender=0x18f170, m=<optimized out>, local_signal_index=<optimized out>, argv=0xff882980) at kernel/qobject.cpp:3547 #17 0xf6ead45c in QSocketNotifier::activated (this=0x18f170, _t1=10) at .moc/release-shared/moc_qsocketnotifier.cpp:103 #18 0xf6e5d72c in QSocketNotifier::event (this=0x18f170, e=0xff882f64) at kernel/qsocketnotifier.cpp:317 #19 0xf62e2ef4 in notify_helper (e=0xff882f64, receiver=0x18f170, this=0x4ac30) at kernel/qapplication.cpp:4556 #20 QApplicationPrivate::notify_helper (this=0x4ac30, receiver=0x18f170, e=0xff882f64) at kernel/qapplication.cpp:4528 #21 0xf62e8e3c in QApplication::notify (this=0xff883330, receiver=0x18f170, e=0xff882f64) at kernel/qapplication.cpp:4417 #22 0xf74e9730 in KApplication::notify (this=0xff883330, receiver=0x18f170, event=0xff882f64) at ../../kdeui/kernel/kapplication.cpp:311 #23 0xf6e39488 in QCoreApplication::notifyInternal (this=0xff883330, receiver=0x18f170, event=0xff882f64) at kernel/qcoreapplication.cpp:915 #24 0xf6e72ee0 in sendEvent (event=0xff882f64, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231 #25 socketNotifierSourceDispatch (source=0x4d440) at kernel/qeventdispatcher_glib.cpp:110 #26 0xf562d2e0 in g_main_context_dispatch () from /lib/sparc-linux-gnu/libglib-2.0.so.0 #27 0xf562d6c0 in ?? () from /lib/sparc-linux-gnu/libglib-2.0.so.0 #28 0xf562d6c0 in ?? () from /lib/sparc-linux-gnu/libglib-2.0.so.0 Backtrace stopped: previous frame identical to this frame (corrupt stack?) In my case of the SPARC64 I simply removed all the code involved in keeping track of all previous lines of output, so now I can't scroll up in konsole, and it no longer crashes, this is no fix but it helps isolate the problem for me anyways. I can begin to figure out why the call to CompactHistoryLines causes the Bus Error. I checked out the latest sources for Konsole from git, and for my case it's looking like the custom new operator to allocate HistoryLines using CompactHistoryBlockList is running over the execution stack. If I simply have the allocation for new lines occur using the heap this issue goes away. Going to try to debug the CompactHistoryBlockList more. 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; }; Created attachment 82182 [details]
Patch for History.h in Konsole to fix Bus Error on SPARCv8 and v9
This changes the memory alignment for the CompactHistoryBlock class from 8-bit, which causes a bus error on SPARCv8-9, and changes it to 32-bit alignment.
Dear Bug Submitter, This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond. Thank you for helping us make KDE software even better for everyone! (In reply to Andrew Crouthamel from comment #6) > re-test if the bug is valid I have no means of reproducing this crash on demand, and I have not experienced it again. Thanks for the update! |