Author Topic: Code autocompletion hangs Code::Blocks  (Read 8371 times)

Offline Totoxa

  • Multiple posting newcomer
  • *
  • Posts: 32
Code autocompletion hangs Code::Blocks
« on: November 12, 2017, 01:03:15 am »
Hi,

I found that Code::Blocks hangs when using autocompletion and the declaration being autocompleted is too long for the space available.
By resizing the editor window and triggering autocompletion I was able to reproduce this problem.

See the attached screenshot and project.

PD: I'm running Debian testing with official packages (Release 16.01 rev 10692, SDK version 1.29.0, wx3.0.3)
« Last Edit: November 12, 2017, 01:07:52 am by Totoxa »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code autocompletion hangs Code::Blocks
« Reply #1 on: November 15, 2017, 08:24:39 pm »
What happens if you try some of the latest night builds or even 17.xx-rc1?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Totoxa

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: Code autocompletion hangs Code::Blocks
« Reply #2 on: November 16, 2017, 08:39:31 am »
Tried the latest nighty build and the RC from jens repository, they both show the problem.

Note that to reproduce the problem you have to enable "Documentation popup" in the General settings, I have disabled that and the problem is gone (anyway I didn't use that feature).

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code autocompletion hangs Code::Blocks
« Reply #3 on: November 16, 2017, 11:09:08 am »
Ok, I'll see if it reproduces on my end.
Can you try to provide an example which is self sufficient?
No includes, just simple code which is enough to reproduce the problem.

I'm asking this because sometimes the code in the toolchain/OS is different and on different system the problem doesn't manifest.

The simplest would probably be if you generate the preprocessed source (gcc -E ....) and use it.

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Totoxa

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: Code autocompletion hangs Code::Blocks
« Reply #4 on: November 16, 2017, 11:43:13 am »
I've attached a project with no includes.

There are two function declarations, one uses stdint types as arguments and the other uses unsigned int, only the first triggers the problem.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code autocompletion hangs Code::Blocks
« Reply #5 on: November 17, 2017, 07:32:34 am »
I cannot reproduce it here.
Can you try to reproduce the problem using just base types?
The uintXXX_t types are typedefs defined in some header the compiler knows about.
For example use
Code
typedef int myint32;

Also can you post a backtrace of the hang using gdb?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Totoxa

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: Code autocompletion hangs Code::Blocks
« Reply #6 on: November 20, 2017, 03:00:24 am »
Hi,

I cannot reproduce it using custom types. I was able to reproduce the problem using uint16_t and uint32_t types, with uint8_t nothing happens, No #includes.
It seems that codeblocks internally handle those types differently.

I made a screencast trying to reproduce the problem and attached a backtrace using the debian version (they had a -dbg package for codeblocks).
I made the screencast with factory settings, in the middle I disabled the symbol browser and the "parse documentation" checkbox in the editor settings.
If you cannot reproduce the problem make the edit pane smaller and try again.

Here is the screencast, please download it and play with vlc or other player, the webplayer doesn't owrk (at least for me)
https://www.dropbox.com/s/4khjd022ddv022f/Captura%20del%20escritorio%20de%2019-11-17%2022%3A00%3A37.webm?dl=0

Offline Totoxa

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: Code autocompletion hangs Code::Blocks
« Reply #7 on: November 20, 2017, 04:09:56 am »
I compiled codeblocks from sources and found that it hangs in the following line

ccmanager.cpp
Code
bool UnfocusablePopupWindow::Show(bool show)
{
    bool rv = BaseClass::Show(show); // in this call C::B hangs

with the following call stack
Code
#0  0x00007ffff2f9d7e3 in UnfocusablePopupWindow::Show(bool) (this=0x55555635f980, show=true) at /tmp/codeblocks-16.01.release/src/sdk/ccmanager.cpp:238
#1  0x00007ffff2fa435e in CCManager::DoShowDocumentation(cbEditor*) (this=0x5555592a7e00, ed=0x5555595c36f0) at /tmp/codeblocks-16.01.release/src/sdk/ccmanager.cpp:1241
#2  0x00007ffff2fa3952 in CCManager::OnTimer(wxTimerEvent&) (this=0x5555592a7e00, event=...) at /tmp/codeblocks-16.01.release/src/sdk/ccmanager.cpp:1127
#3  0x00007ffff385b2ce in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#4  0x00007ffff385b6da in wxEvtHandler::SearchDynamicEventTable(wxEvent&) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#5  0x00007ffff385b76f in wxEvtHandler::TryHereOnly(wxEvent&) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#6  0x00007ffff385b823 in wxEvtHandler::ProcessEventLocally(wxEvent&) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#7  0x00007ffff385b885 in wxEvtHandler::ProcessEvent(wxEvent&) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#8  0x00007ffff385b5e7 in wxEvtHandler::SafelyProcessEvent(wxEvent&) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#9  0x00007ffff37bfb41 in wxTimerImpl::SendEvent() () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#10 0x00007ffff41e7181 in  () at /usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0
#11 0x00007ffff5e4f853 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#12 0x00007ffff5e4edd5 in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#13 0x00007ffff5e4f1a0 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#14 0x00007ffff5e4f4b2 in g_main_loop_run () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#15 0x00007ffff78bf3b7 in gtk_main () at /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
#16 0x00007ffff41d44d5 in wxGUIEventLoop::DoRun() () at /usr/lib/x86_64-linux-gnu/libwx_gtk2u_core-3.0.so.0
#17 0x00007ffff3717b23 in wxEventLoopBase::Run() () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#18 0x00007ffff36df046 in wxAppConsoleBase::MainLoop() () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#19 0x00005555555ffd17 in CodeBlocksApp::OnRun() (this=0x555555a44940) at /tmp/codeblocks-16.01.release/src/src/app.cpp:850
#20 0x00007ffff3769e19 in wxEntry(int&, wchar_t**) () at /usr/lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
#21 0x00005555555fd0d9 in main(int, char**) (argc=8, argv=0x7fffffffe6e8) at /tmp/codeblocks-16.01.release/src/src/app.cpp:322

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code autocompletion hangs Code::Blocks
« Reply #8 on: November 21, 2017, 07:06:49 am »
This sounds like a bug in UnfocusablePopupWindow under Linux.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Totoxa

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: Code autocompletion hangs Code::Blocks
« Reply #9 on: December 24, 2017, 07:06:16 am »
This sounds like a bug in UnfocusablePopupWindow under Linux.

So I should write a bug report to wxWidgets, I don't think they will take me seriously with this use case, For now the workaround is to disable the feature.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code autocompletion hangs Code::Blocks
« Reply #10 on: December 24, 2017, 02:07:38 pm »
Nope, I doubt the problem is in UnfocusablePopupWindow.
But we need some way to reproduce this problem on something different than debian.
I'm using gentoo and have several ubuntu vms setup, so if you can reproduce this in some ubuntu it might make it easier for me to debug.

Also what desktop env/wm are you using?

Another thing:
Can you enable asan or use valgrind to see if there is some memory corruption somewhere?
What are the values of the variables at the moment of the crash (this, other locals and members)?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Totoxa

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: Code autocompletion hangs Code::Blocks
« Reply #11 on: December 24, 2017, 08:15:21 pm »
Nope, I doubt the problem is in UnfocusablePopupWindow.
But we need some way to reproduce this problem on something different than debian.
I'm using gentoo and have several ubuntu vms setup, so if you can reproduce this in some ubuntu it might make it easier for me to debug.

Also what desktop env/wm are you using?

Another thing:
Can you enable asan or use valgrind to see if there is some memory corruption somewhere?
What are the values of the variables at the moment of the crash (this, other locals and members)?

Ok, tell me what version of Ubuntu should I setup in a VM to try to reproduce the problem.

I'm using GNOME in Debian testing, I will try to get something from valgrind (I have never used it).

Thanks

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code autocompletion hangs Code::Blocks
« Reply #12 on: December 25, 2017, 04:38:56 pm »
I think I have 17.04...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code autocompletion hangs Code::Blocks
« Reply #13 on: January 06, 2018, 12:27:26 pm »
Any progress with reproducing this on ubuntu?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Totoxa

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: Code autocompletion hangs Code::Blocks
« Reply #14 on: June 08, 2018, 01:33:34 am »
Any progress with reproducing this on ubuntu?

Sorry, I completely forgot about this, the forums doesn't send email notifications?.

Fortunately another C::B user was also hit by this problem and solved it [1]. I noticed because a bug report on kicad [2].

[1] https://sourceforge.net/p/codeblocks/tickets/701/
[2] https://bugs.launchpad.net/kicad/+bug/1767848