News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Crash using copy and paste (reproducable)

Started by Pulle, December 07, 2006, 08:30:16 PM

Previous topic - Next topic

Pulle

Although this bug is already reported on the BerliOs-ProjectPage, I decided to start a new thread because I've found a way to reproduce this crash and to show that this bug is still existant in current svn-versions.

The problem: CodeBlocks crashes quite often when doing copy & paste. I don't know if it depends on the text which should be pasted, but this is the way I can reproduce the crash:
1. start C::B and open or create an empty cpp-file.
2. paste the following code "as it is" into the empty cpp-file

#include <gtkmm.h>
#include <gtkmm/button.h>
#include <gtkmm/image.h>
#include <libglademm-2.4/libglademm/xml.h>
#include <iostream>

3. mark the complete code in the cpp-file.
4. press copy and then paste and C::B should crash.

The crash happens very often and not only when pasting this special piece of code, but this special case was the only one I found to reproduce it.

I'm using Arch-Linux 0.7.2:
uname -a
2.6.18-ARCH #1 SMP PREEMPT Thu Nov 30 21:32:54 CET 2006 i686 AMD Athlon(tm) 64 Processor 3200+ AuthenticAMD GNU/Linux

The bug occured with
svn build rev 3353 (2006-12-07 14:49:33) gcc 4.1.2 Linux/unicode
as well as with a version from the 3rd of december (don't remember the version-number).

Here's the backtrace:
codeblocks -d
*** glibc detected *** codeblocks: double free or corruption (!prev): 0x08c5a0d8 ***
======= Backtrace: =========
/lib/libc.so.6[0xb72fdb10]
/lib/libc.so.6(__libc_free+0x89)[0xb72ff1a9]
/usr/lib/libwx_gtk2u_core-2.6.so.0[0xb773fe3c]
/usr/lib/libgtk-x11-2.0.so.0[0xb6ff89c6]
/usr/lib/libgobject-2.0.so.0(g_closure_invoke+0x13b)[0xb6e3007b]
/usr/lib/libgobject-2.0.so.0[0xb6e404e9]
/usr/lib/libgobject-2.0.so.0(g_signal_emit_valist+0x899)[0xb6e419a9]
/usr/lib/libgobject-2.0.so.0(g_signal_emit_by_name+0xee)[0xb6e4475e]
/usr/lib/libgtk-x11-2.0.so.0[0xb70556e4]
/usr/lib/libgtk-x11-2.0.so.0(gtk_selection_convert+0x145)[0xb7056565]
/usr/lib/libwx_gtk2u_core-2.6.so.0(_ZN11wxClipboard7GetDataER12wxDataObject+0x1ec)[0xb774009c]
/usr/local/lib/libcodeblocks.so.0(_ZN11ScintillaWX5PasteEv+0x17f)[0xb7d9a04f]
/usr/local/lib/libcodeblocks.so.0(_ZN6Editor7WndProcEjml+0x1c5a)[0xb7dc77ba]
/usr/local/lib/libcodeblocks.so.0(_ZN13ScintillaBase7WndProcEjml+0x2b7)[0xb7e4c437]
/usr/local/lib/libcodeblocks.so.0(_ZN11ScintillaWX7WndProcEjml+0x44)[0xb7d985c4]
/usr/local/lib/libcodeblocks.so.0(_ZN11wxScintilla7SendMsgEill+0x2f)[0xb7d9ca0f]
/usr/local/lib/libcodeblocks.so.0(_ZN11wxScintilla5PasteEv+0x32)[0xb7d9f062]
/usr/local/lib/libcodeblocks.so.0(_ZN8cbEditor5PasteEv+0x25)[0xb7bd6d95]
codeblocks(_ZN9MainFrame11OnEditPasteER14wxCommandEvent+0x38)[0x807aff8]
/usr/lib/libwx_baseu-2.6.so.0(_ZNK12wxAppConsole11HandleEventEP12wxEvtHandlerMS0_FvR7wxEventES3_+0x35)[0xb7533395]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler21ProcessEventIfMatchesERK21wxEventTableEntryBasePS_R7wxEvent+0x92)[0xb75bf662]
/usr/lib/libwx_baseu-2.6.so.0(_ZN16wxEventHashTable11HandleEventER7wxEventP12wxEvtHandler+0x7b)[0xb75bf7ab]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0xcf)[0xb75bf91f]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_baseu-2.6.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x6e)[0xb75bf8be]
/usr/lib/libwx_gtk2u_core-2.6.so.0[0xb77c0568]
/usr/lib/libgobject-2.0.so.0(g_cclosure_marshal_VOID__VOID+0x4b)[0xb6e3d41b]
/usr/lib/libgobject-2.0.so.0(g_closure_invoke+0x13b)[0xb6e3007b]
/usr/lib/libgobject-2.0.so.0[0xb6e404e9]
/usr/lib/libgobject-2.0.so.0(g_signal_emit_valist+0x899)[0xb6e419a9]
/usr/lib/libgobject-2.0.so.0(g_signal_emit+0x29)[0xb6e41b59]
/usr/lib/libgtk-x11-2.0.so.0[0xb711002d]
/usr/lib/libgobject-2.0.so.0(g_closure_invoke+0x13b)[0xb6e3007b]
/usr/lib/libgobject-2.0.so.0[0xb6e404e9]
/usr/lib/libgobject-2.0.so.0(g_signal_emit_valist+0x678)[0xb6e41788]
======= Memory map: ========
08048000-080df000 r-xp 00000000 03:02 121214     /usr/local/bin/codeblocks
080df000-080e5000 rwxp 00096000 03:02 121214     /usr/local/bin/codeblocks
080e5000-08cd4000 rwxp 080e5000 00:00 0          [heap]
b285b000-b285c000 ---p b285b000 00:00 0
b285c000-b305c000 rwxp b285c000 00:00 0
b305c000-b3068000 r-xp 00000000 03:02 121681     /usr/share/fonts/TTF/VeraMoBd.ttf
b3068000-b3069000 ---p b3068000 00:00 0
b3069000-b3869000 rwxp b3069000 00:00 0
b3869000-b3876000 r-xp 00000000 03:02 121680     /usr/share/fonts/TTF/VeraMono.ttf
b3876000-b388c000 r-xp 00000000 03:02 121460     /usr/local/share/codeblocks/plugins/libcb_koders.so
b388c000-b388d000 rwxp 00016000 03:02 121460     /usr/local/share/codeblocks/plugins/libcb_koders.so
b388d000-b388e000 ---p b388d000 00:00 0
b388e000-b408e000 rwxp b388e000 00:00 0
b408e000-b4130000 r-xp 00000000 03:02 121260     /usr/local/share/codeblocks/plugins/libcodecompletion.so
b4130000-b4135000 rwxp 000a1000 03:02 121260     /usr/local/share/codeblocks/plugins/libcodecompletion.so
b4135000-b413d000 rwxp b4135000 00:00 0
b413d000-b4150000 r-xp 00000000 03:02 121491     /usr/local/share/codeblocks/plugins/libhelp_plugin.so
b4150000-b4151000 rwxp 00013000 03:02 121491     /usr/local/share/codeblocks/plugins/libhelp_plugin.so
b4151000-b4161000 r-xp 00000000 03:02 121231     /usr/local/share/codeblocks/plugins/libclasswizard.so
b4161000-b4162000 rwxp 00010000 03:02 121231     /usr/local/share/codeblocks/plugins/libclasswizard.so
b4162000-b4170000 r-xp 00000000 03:02 121485     /usr/local/shaAbgebrochen

Pulle

#1
I've done a bit more testing and recognized that this crash only occurs when C::B is build with the unicode-version of wxgtk. If I built it with the ansi-version the crash was gone. Maybe it's not a C::B error but a wxwidgets error but I didn't recognized it with any other wxwidgets-apps.

sethjackson

wxScintilla Unicode handling problem (just a guess)?

stonedz

Hello,

I have the exact same problem with the same configuration (Archlinux updated to current), It seems that our distro config may be the cause of this problem. Meanwhile, if someone get a clue about how to patch it it would be nice, it's annoying not being able to copy/paste (sic!) in an IDE...

Thanks.

Pecan

Quote from: stonedz on December 12, 2006, 02:08:05 AM
Hello,

I have the exact same problem with the same configuration (Archlinux updated to current), It seems that our distro config may be the cause of this problem. Meanwhile, if someone get a clue about how to patch it it would be nice, it's annoying not being able to copy/paste (sic!) in an IDE...

Thanks.

Turn off CodeCompletion and see if the problem goes away.

eranif

#5
Hi,
Couple of months ago I encountered the same problem I posted this issue at wxCode forum, but unfortunaly I got no replies but one, but I did managed to find a solution for this
(it is, in my opinion wxScintilla bug)

the bug report and the solution can be found here:
http://wxforum.shadonet.com/viewtopic.php?t=9907

A quick solution is to replace the Paste function with this one: (ScintillWX.cpp):
void ScintillaWX::Paste() {
    pdoc->BeginUndoAction();
    ClearSelection();

#if wxUSE_DATAOBJ
    wxTextDataObject data;
    wxString textString;

    wxWX2MBbuf buf;
    int   len  = 0;
    bool  rectangular = false;

    if (wxTheClipboard->Open()) {
        wxTheClipboard->UsePrimarySelection(false);
        wxCustomDataObject selData(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_PRIVATE);
        bool gotRectData = wxTheClipboard->GetData(selData);

        if (gotRectData && selData.GetSize()>1) {
            const char* rectBuf = (const char*)selData.GetData();
            rectangular = rectBuf[0] == (char)1;
            len = selData.GetDataSize()-1;
            char* buffer = new char[len];
            memcpy (buffer, rectBuf+1, len);
            textString = sci2wx(buffer, len);
            delete buffer;
        } else {
            bool gotData = wxTheClipboard->GetData(data);
            if (gotData) {
                textString = wxTextBuffer::Translate (data.GetText(),
                                                      wxConvertEOLMode(pdoc->eolMode));
            }
        }
        data.SetText(wxEmptyString); // free the data object content
        wxTheClipboard->Close();
    }

    buf = (wxWX2MBbuf)wx2sci(textString);
    len  = strlen(buf);
    int newPos = 0;
    if (rectangular) {
        int newLine = pdoc->LineFromPosition (currentPos) + wxCountLines (buf, pdoc->eolMode);
        int newCol = pdoc->GetColumn(currentPos);
        PasteRectangular (currentPos, buf, len);
        newPos = pdoc->FindColumn (newLine, newCol);
    } else {
        pdoc->InsertString (currentPos, buf, len);
        newPos = currentPos + len;
    }
    SetEmptySelection (newPos);
#endif // wxUSE_DATAOBJ

    pdoc->EndUndoAction();
    NotifyChange();
    Redraw();
}

Eran

manciuleas

Eran,

Who is wxCountLines? It seems that it is not defined.

stahta01

#7
Quote from: manciuleas on December 12, 2006, 05:52:03 PM
Eran,

Who is wxCountLines? It seems that it is not defined.


From ScintillaWX.cxx right after the wxConvertEOLMode method; this is from code written after C::B version of it.

static int wxCountLines(const char* text, int scintillaMode)
{
    char eolchar;

    switch (scintillaMode) {
        case wxSCI_EOL_CRLF:
        case wxSCI_EOL_LF:
            eolchar = '\n';
            break;
        case wxSCI_EOL_CR:
            eolchar = '\r';
            break;
        default:
            return 0;
    }

    int count = 0;
    int i     = 0;
    while (text[i] != 0) {
        if (text[i] == eolchar) {
            count++;
        }
        i++;
    }

    return count;
}
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

manciuleas


Pulle

Hi,
thanks for the help Eran, but the bug is still there after changing ScintillaWX.cpp as you suggested and recompile C::B. So the error must be somewhere else.
btw: disabling code-completition didn't helped either.

eranif

This is wierd, since this function fixed the same problem for me. can you confirm that the wxUSE_UNICODE macro is set to 1?
Eran

Pulle

Yes, wxUSE_UNICODE is set to 1 in the setup.h.

fleuba

Hi,

just wanted to ask WHEN will this bug be fixed in the svn source tree ?
It has been reported for more than 2 month, it is critical, and though we see no sign of move on this topic.
Is someone working on a patch ? will it be applied to the svn source tree ? when ?
Please could you give some feedbacks, it would be nice  :?.

Thanks for this great IDE, it is for us who work on many plateform (windows, linux32, linux64, MacOS) a really great tool.

Fred

Biplab

#13
This is bugging me too. I'm using C::B Revison 3593, OpenSUSE 10.2, wxGTK-2.6.3.1 and wx is compiled as Release-Dynamic-Unicode-Monolithic.

C::B crashes after using Ctrl+V or Edit>Paste.
Be a part of the solution, not a part of the problem.

mandrav

Quotejust wanted to ask WHEN will this bug be fixed in the svn source tree ?
It has been reported for more than 2 month, it is critical, and though we see no sign of move on this topic.
Is someone working on a patch ? will it be applied to the svn source tree ? when ?

When it is fixed.

For the curious, neither me nor any other core team member is able to reproduce this. This means that until a patch is contributed by someone else, there is little to be done.
Be patient!
This bug will be fixed soon...