question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot Debug in CLion on Ubuntu: GDB gives timeout error

See original GitHub issue

The Problem

A CLion/GDB timeout error occurs whenever I try to debug a cc_test target in a modestly-sized Bazel project with manually set --cxxopt in the .bazelrc file. Therefore, I can no longer use the CLion debugger on Bazel cc_test targets in one of my projects.

Here is what the timeout error looks like:

CLion GDB Timeout

Notice that the project is being recompiled in the window on the left.

Testing Configurations

I’ve confirmed that this problem exists in at least three configurations:

  • Ubuntu 19.04
  • CLion v2019.1.3
  • Bazel v0.25.2
  • bazelbuild/intellij plugin:
    • v2019.05.01.0.3
    • v2019.05.13.0.2
    • commit eaeaf473

(I’ve also seen this problem with other recent versions of the plugin, but I haven’t recorded exactly which. I describe an older working configuration below under “Successful Workaround”, so the problem probably started sometime since January.)

Test Project

I’ve made a simple Bazel project, dwtj/ex_clion_bazel_plugin_gdb_timeout, to help demonstrate the problem.

This project just contains:

  • A .bazelrc file with explicitly set --cxxopt='-std=c++14'
  • A trivial cc_test target
  • A protobuf target on which the cc_test depends.

(The protobuf dependency is just here to extends compile time long enough to trigger the timeout. If you can’t reproduce the GDB timeout on your system, try adding some more work for the compiler to do.)

On my system, attempts to debug the hello target always time out 10-15 seconds after the “Debug” toolbar opens. The error message always looks like this:

Steps to Reproduce

  1. Import test project into CLion.
  2. Follow the two workarounds which I described in issue #525:
    • select a custom GDB executable (e.g. /usr/bin/gdb)
    • run chmod u+x gdbserver
  3. Create a CLion Run/Debug Configuration from the “Bazel Command” template with target expression //:hello and Bazel command test.
  4. Debug this configuration.

On my system, I then observe the following:

  1. “Bazel Console” starts “Building debug binary”. (See attached log file.)
  2. Once compilation completes, the “Debug” Toolbar becomes visible, and its “Console” tab starts “Running debug binary”. However, this console does not just run/debug the binary; it appears to perform the compilation all over again. (See attached log file.)
  3. About 10-15 seconds after this the red timeout popup appears (pictured above).

Workarounds

Unsuccessful Workaround 1: Modify CLion Registry to Lengthen Debugger Timeout

After some googling, I found this JetBrains article: Adjusting GDB start-up time out value. However, making this value either small or large made no difference: the red timeout error happened after about fifteen seconds either way.

Unsuccessful Workaround 2: Lengthen the --test_timeout Argument of the bazel invocation.

I tried modifying the plugin slightly so that the bazel invocations being run have a much longer --test_timeout. Increasing it from 3600 to 36000000 did not prevent the GDB timeout error.

Successful Workaround: Revert To Old Versions

I’ve reverted to older releases, specifically, CLion v2018.3.4, Bazel v0.22.0, and bazelbuild/intellij plugin v2019.01.14.0.5.

Attachments

bazel_console.log debug_console.log

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:7

github_iconTop GitHub Comments

2reactions
dwtjcommented, Jul 17, 2019

This issue appears to still affect the latest releases. I can reproduce this issue in the following configurations:

  • Ubuntu 18.04
  • CLion 2019.1.4
  • Bazel 0.28.0
  • bazelbuild/intellij plugin
    • v2019.06.17.0.1
    • commit c0e8fdfb (committed today)

Note that I updated the example repo slightly in order to make it buildable by Bazel 0.28.0 (e.g. updated protobuf).

0reactions
zhukercommented, Jul 11, 2021

Can someone look into this please? CLion 2020.3 Bazel 2021.06.15.0.4 Removing --cxxopt='-std=c++17' from .bazelrc as suggested above used to work before now it doesn’t

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command timed out problem with CLion 2016.3.2 : CPP-8842
It's sent by CLion when closing a debug session, in this case as a result of a timeout error. So that's doesn't look...
Read more >
GDB Remote Debug with CLion not working - Stack Overflow
In the bottom of the IDE I see this message: IBus prior to 1.5. · FYI: your issue seems to be caused by...
Read more >
Debugging with GDB - sourceware.org
The problem is the restrictions on the use of the manual. Free manuals are available in source code form, and give you permission...
Read more >
Leveling up your GDB flow with CLion - Undo.io
In this GDB tutorial, Phil Nash from JetBrains shows you tips and tricks ... Where debugging in CLion really shines though, is where...
Read more >
Debugging your program using Valgrind's gdbserver and GDB
The simplest way to get started is to run Valgrind with the flag --vgdb-error=0 . Then follow the on-screen directions, which give you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found