[Kde-bindings] Segfault (as promised)
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Sun Oct 3 10:03:38 UTC 2004
On Sunday 03 October 2004 10:29, Han Holl wrote:
> Hi Richard,
>
> Here's an example of a segfault caused by a _very_ simple programming
> error:
>
> require 'Qt'
>
> class Segdemo < Qt::Widget
> def initialize(*k)
> super(*k)
> # The next line should be: lay = Qt::HBoxLayout.new(self)
> lay = Qt::HBoxLayout
> ed = Qt::LineEdit.new('blah',self)
> lay.addWidget(ed)
> end
> end
>
> if $0 == __FILE__
> a = Qt::Application.new(ARGV)
> w = Segdemo.new
> a.mainWidget = w
> w.show
> a.exec
> end
>
> On my system: Linux RH9, ruby-1.8.1, gcc 3.2.2, qtruby-cvs-2004-09-13,
> qt-3.1.1 this produces:
>
> client.rb:9: [BUG] Segmentation fault
> ruby 1.8.1 (2004-03-08) [i686-linux-gnu]
>
> Aborted
>
> I would have expected a NoMethodError for Qt::HBoxLayout:Class
>
> If you need anything else please let me know.
Thanks for that, it crashes very nicely :). The problem is that the QtRuby
runtime calls the addWidget() method on a null C++ instance. So it needs to
check in the Smoke runtime whether or not the C++ method is static. I
remember having a discussion with the PerlQt guys once, and we decided it
wasn't a good idea to check for that, because it would cause more problems
than it would solve. I'll have to think about that again. Maybe it's a
problem that PerlQt has which doesn't apply to QtRuby.
-- Richard
#4 0x0d6e6ec8 in QLayout::mainWidget() ()
from /home/duke/src/kde/HEAD/qt-copy/lib/libqt-mt.so.3
#5 0x0d6e6eac in QLayout::mainWidget() ()
from /home/duke/src/kde/HEAD/qt-copy/lib/libqt-mt.so.3
#6 0x0d739bfc in QBoxLayout::insertWidget(int, QWidget*, int, int) ()
from /home/duke/src/kde/HEAD/qt-copy/lib/libqt-mt.so.3
#7 0x0d739d28 in QBoxLayout::addWidget(QWidget*, int, int) ()
from /home/duke/src/kde/HEAD/qt-copy/lib/libqt-mt.so.3
#8 0x0f7c2ce0 in xcall_QBoxLayout(short, void*, Smoke::StackItem*) ()
from /opt/kde3/lib/libsmokekde.so.1
#9 0x0fc641c8 in class_method_missing ()
More information about the Kde-bindings
mailing list