Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

Is CC crash, or Debugger plugin?

<< < (21/23) > >>

oBFusCATed:
I have new deadlock here (debugger branch r7444) :

--- Code: ---(gdb) bt
#0  0x000000373d60d4c4 in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x000000373d608e1a in _L_lock_1034 () from /lib64/libpthread.so.0
#2  0x000000373d608cdc in pthread_mutex_lock () from /lib64/libpthread.so.0
#3  0x0000003744cfa3e9 in wxMutexInternal::Lock (this=<value optimized out>) at ./src/unix/threadpsx.cpp:248
#4  0x00002ba4c8de5b1b in wxCriticalSection::Enter (this=0x2aaab3e9a980) at /usr/include/wx-2.8/wx/thread.h:271
#5  0x00002ba4c8de5b45 in wxCriticalSectionLocker::wxCriticalSectionLocker (this=0x7fffba483d50, cs=...) at /usr/include/wx-2.8/wx/thread.h:286
#6  0x00002aaab3c03ee3 in Parser::IsFileParsed (this=0x4ee4400, filename=...) at parser/parser.cpp:1308
#7  0x00002aaab3bf321c in NativeParser::GetProjectByFilename (this=0x3ede040, filename=...) at nativeparser.cpp:269
#8  0x00002aaab3bb88b0 in CodeCompletion::OnReparsingTimer (this=0x3eddfc0, event=...) at codecompletion.cpp:1935
#9  0x0000003744cfcbff in wxEvtHandler::ProcessEventIfMatches (entry=<value optimized out>, handler=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1239
#10 0x0000003744cfcd9f in wxEventHashTable::HandleEvent (this=<value optimized out>, event=<value optimized out>, self=<value optimized out>) at ./src/common/event.cpp:906
#11 0x0000003744cfcee9 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1301
#12 0x0000003b39af2106 in wxTimerBase::Notify (this=<value optimized out>) at ./src/common/timercmn.cpp:57
#13 0x0000003b399ed2e3 in timeout_callback (data=<value optimized out>) at ./src/gtk/timer.cpp:45
#14 0x000000373ee2d2bb in ?? () from /lib64/libglib-2.0.so.0
#15 0x000000373ee2cdb4 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#16 0x000000373ee2fc0d in ?? () from /lib64/libglib-2.0.so.0
#17 0x000000373ee2ff1a in g_main_loop_run () from /lib64/libglib-2.0.so.0
#18 0x0000003b3872aa63 in gtk_main () from /usr/lib64/libgtk-x11-2.0.so.0
#19 0x0000003b399e456d in wxEventLoop::Run (this=<value optimized out>) at ./src/gtk/evtloop.cpp:76
#20 0x0000003b39a3b5d1 in wxDialog::ShowModal (this=<value optimized out>) at ./src/gtk/dialog.cpp:146
#21 0x0000003b39b017ed in wxGetSingleChoiceIndex (message=<value optimized out>, caption=<value optimized out>, n=<value optimized out>, choices=<value optimized out>, parent=<value optimized out>) at ./src/generic/choicdgg.cpp:127
#22 0x0000003b39b01915 in wxGetSingleChoiceIndex (message=<value optimized out>, caption=<value optimized out>, aChoices=<value optimized out>, parent=<value optimized out>, x=<value optimized out>, y=<value optimized out>, centre=<value optimized out>, width=Could not find the frame base for "wxGetSingleChoiceIndex(wxString const&, wxString const&, wxArrayString const&, wxWindow*, int, int, bool, int, int)".
)
    at ./src/generic/choicdgg.cpp:146
#23 0x00002aaab3bc7d26 in CodeCompletion::OnGotoDeclaration (this=0x3eddfc0, event=...) at codecompletion.cpp:2932
#24 0x0000003744cfcbff in wxEvtHandler::ProcessEventIfMatches (entry=<value optimized out>, handler=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1239
#25 0x0000003744cfcd9f in wxEventHashTable::HandleEvent (this=<value optimized out>, event=<value optimized out>, self=<value optimized out>) at ./src/common/event.cpp:906
#26 0x0000003744cfcee9 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1301
#27 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#28 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#29 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#30 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#31 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#32 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#33 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#34 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#35 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#36 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#37 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#38 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#39 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#40 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#41 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#42 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#43 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#44 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#45 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#46 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#47 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#48 0x0000003b39af8b46 in wxWindowBase::TryParent (this=<value optimized out>, event=<value optimized out>) at ./src/common/wincmn.cpp:2661
#49 0x0000003744cfce90 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1314
#50 0x0000003744cfce80 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1308
#51 0x0000003b39af8b46 in wxWindowBase::TryParent (this=<value optimized out>, event=<value optimized out>) at ./src/common/wincmn.cpp:2661
#52 0x0000003744cfce90 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1314
#53 0x0000003b39af8b46 in wxWindowBase::TryParent (this=<value optimized out>, event=<value optimized out>) at ./src/common/wincmn.cpp:2661
#54 0x0000003744cfce90 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1314
#55 0x00002aaab6f71ced in wxMenuCmd::Exec (this=0x4e89950, origin=0x2aaaac219ac0, client=0x2aaaac219ac0) at menuutils.cpp:543
#56 0x00002aaab6f64b11 in wxKeyBinder::OnChar (this=0x4e71880, event=..., next=0x2aaaac219ac0) at keybinder.cpp:1429
#57 0x00002aaab6f64c3b in wxBinderEvtHandler::OnChar (this=0x2aaaac21bc70, p=...) at keybinder.cpp:791
#58 0x0000003744cfcbff in wxEvtHandler::ProcessEventIfMatches (entry=<value optimized out>, handler=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1239
#59 0x0000003744cfcd9f in wxEventHashTable::HandleEvent (this=<value optimized out>, event=<value optimized out>, self=<value optimized out>) at ./src/common/event.cpp:906
#60 0x0000003744cfcee9 in wxEvtHandler::ProcessEvent (this=<value optimized out>, event=<value optimized out>) at ./src/common/event.cpp:1301
#61 0x0000003b399f8ef6 in gtk_window_key_press_callback (widget=<value optimized out>, gdk_event=<value optimized out>, win=<value optimized out>) at ./src/gtk/window.cpp:1034
#62 0x0000003b3872ffcd in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
#63 0x000000373f60b08a in g_closure_invoke () from /lib64/libgobject-2.0.so.0
#64 0x000000373f61b2ed in ?? () from /lib64/libgobject-2.0.so.0
---Type <return> to continue, or q <return> to quit---
#65 0x000000373f61c516 in g_signal_emit_valist () from /lib64/libgobject-2.0.so.0
#66 0x000000373f61c923 in g_signal_emit () from /lib64/libgobject-2.0.so.0
#67 0x0000003b3882d79e in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
#68 0x0000003b3883b7fb in gtk_window_propagate_key_event () from /usr/lib64/libgtk-x11-2.0.so.0
#69 0x0000003b3883e57b in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
#70 0x0000003b3872ffcd in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
#71 0x000000373f60b08a in g_closure_invoke () from /lib64/libgobject-2.0.so.0
#72 0x000000373f61b8e6 in ?? () from /lib64/libgobject-2.0.so.0
#73 0x000000373f61c516 in g_signal_emit_valist () from /lib64/libgobject-2.0.so.0
#74 0x000000373f61c923 in g_signal_emit () from /lib64/libgobject-2.0.so.0
#75 0x0000003b3882d79e in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
#76 0x0000003b38729785 in gtk_propagate_event () from /usr/lib64/libgtk-x11-2.0.so.0
#77 0x0000003b3872a6d1 in gtk_main_do_event () from /usr/lib64/libgtk-x11-2.0.so.0
#78 0x0000003b3824689c in ?? () from /usr/lib64/libgdk-x11-2.0.so.0
#79 0x000000373ee2cdb4 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#80 0x000000373ee2fc0d in ?? () from /lib64/libglib-2.0.so.0
#81 0x000000373ee2ff1a in g_main_loop_run () from /lib64/libglib-2.0.so.0
#82 0x0000003b3872aa63 in gtk_main () from /usr/lib64/libgtk-x11-2.0.so.0
#83 0x0000003b399e456d in wxEventLoop::Run (this=<value optimized out>) at ./src/gtk/evtloop.cpp:76
#84 0x0000003b39a72378 in wxAppBase::MainLoop (this=<value optimized out>) at ./src/common/appcmn.cpp:312
#85 0x0000000000449d8a in CodeBlocksApp::OnRun (this=0x32d5090) at app.cpp:788
#86 0x0000003744c99cc1 in wxEntry (argc=<value optimized out>, argv=<value optimized out>) at ./src/common/init.cpp:448
#87 0x000000000044d83c in main (argc=1, argv=0x7fffba4867f8) at app.cpp:260

--- End code ---

oBFusCATed:
Loaden:
This is pretty major deadlock here!!!!
Because you are taking the lock in CodeCompletion::OnGotoDeclaration, for very long time (the lock is taken during the dialog.ShowModal()), and if you call a function which takes the lock, you get a deadlock, pretty scary stuff.

One solution is:
0. take the lock
1. generate the list of matches
2. release the lock
3. show the dialog

Keep in mind the the event loop is running when you call ShowModal() and other event handlers could be called.

oBFusCATed:
Here is a patch that should fix the problem: http://smrt.is-a-geek.org/codeblocks/patches/goto_declr_deadlock.patch

Please test and report if there are problems, if there are no problems in the next couple of days, I'll commit it.

ollydbg:

--- Quote from: oBFusCATed on September 14, 2011, 01:43:42 am ---Here is a patch that should fix the problem: http://smrt.is-a-geek.org/codeblocks/patches/goto_declr_deadlock.patch

Please test and report if there are problems, if there are no problems in the next couple of days, I'll commit it.

--- End quote ---
I review the patch, but I don't think this patch release the lock before showing the selection dialog.
After the patch, it looks like:

--- Code: ---
    {
        TRACK_THREAD_LOCKER(s_TokensTreeCritical);
        wxCriticalSectionLocker locker(s_TokensTreeCritical);
        THREAD_LOCKER_SUCCESS(s_TokensTreeCritical);

        TokensTree* tokens = m_NativeParser.GetParser().GetTokensTree();

        .......
        .......

        if (token)
        {
            if (   wxGetKeyState(WXK_CONTROL)
                && wxGetKeyState(WXK_SHIFT)
                && (  event.GetId() == idGotoDeclaration
                   || event.GetId() == idGotoImplementation ) )
            {
                // beware this  code can lead to a deadlock (because of double locking from single thread)
                CCDebugInfo info(nullptr, &m_NativeParser.GetParser(), token);
                info.ShowModal();
            }
            else if (isImpl)
            {
                targetEditor = edMan->Open(token->GetImplFilename());
                editorLine = token->m_ImplLine - 1;
            }
            else if (isDecl)
            {
                targetEditor = edMan->Open(token->GetFilename());
                editorLine = token->m_Line - 1;
            }

            tokenFound = true;
        }
    }

--- End code ---

Still not safe to show the CCDebugInfo dialog.
Can you give some explanation?

oBFusCATed:
Unfortunately you're right :(

p.s. I don't care for CCDebugInfo, it is not something a user uses in his daily programming tasks.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version