[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Input-sequence anomaly

From: Vadim Zeitlin
Subject: Re: [lmi] Input-sequence anomaly
Date: Fri, 12 Feb 2016 00:13:31 +0100

On Thu, 11 Feb 2016 12:12:18 +0000 Greg Chicares <address@hidden> wrote:

GC> On 02/11/2016 04:44 AM, Greg Chicares wrote:
GC> > On 02/11/2016 03:30 AM, Greg Chicares wrote:
GC> > [...]
GC> >> Let's try the last example above in gdb:
GC> > 
GC> > Once more, to localize the problem...looks like it goes haywire in
GC> > InputSequenceEditor::add_row().
GC> Now I've localized it as much as I can in lmi. It runs up to
GC> 'input_sequence_entry.cpp' line 532:
GC>         if(!keywords_only_)
GC>             {
GC>             combo->AutoComplete(kw); // <-- call into wx
GC>             }
GC> where gdb gives a fairly sensible backtrace. When I execute that line,
GC> calling into wx, __cxa_pure_virtual() is trapped, and the backtrace
GC> looks dodgier.

 It took me embarrassingly long to understand what was going on here but,
finally, it's just a bug in wx[*] which was fixed in this commit:


 To quote the commit message:
---------------------------------- >8 --------------------------------------
Don't define interfaces inside anonymous namespace in wxMSW

Some interfaces, notably IAutoCompleteDropDown, but also several other ones in
taskbarbutton.cpp, were defined inside anonymous namespace to avoid clashing
with the interfaces possibly (but not necessarily) declared in the standard

However gcc 4.9 is smart enough to realize that no classes deriving from a
class in an anonymous namespace can exist and so it devirtualizes the calls to
virtual methods of the objects of this type when compiling with optimizations
enabled. And it does it even if it means replacing the call to a virtual
method with just a call to __cxa_pure_virtual(), i.e. crashing during

Prevent it from doing this by moving class declarations outside of the
anonymous namespace and fix the crash when using wxTextEntry::AutoComplete()
in the code compiled with g++ 4.9.
---------------------------------- >8 --------------------------------------

 I.e. the crash was literally due to directly calling __cxa_pure_virtual()
from the code because g++ is now so smart that it convinced itself that no
other function could possibly be called here. The stack "corruption" was
just a red herring, from looking (a lot; I was really missing the forest
behind the trees for a long time here) at the disassembly, g++ uses esp
register much more aggressively now and its value is often temporarily
changed from its "real" value inside a function and so needs to be adjusted
to undo this temporary subtraction to see the real stack.

 Anyhow, the important thing is that with the wxWidgets commit above I
don't see the crash in lmi any longer and the tests pass for me, except for
the 3 failing ones involving Java which I have never installed in the VM
where I tested them.

 Sorry for the inconvenience, but you will have to update wxWidgets once
again to fix this.

[*] Initially I suspected a bug in g++, but actually it's in its right to
    do what it does, it's just not really helpful neither, and I opened
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69777 in an attempt to
    change this. But, to be honest, I don't have a lot of hope that
    anything is really going to happen here.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]