Vscode-cmake-tools: C++ Build stops in last update of vscode

Created on 16 Apr 2018  路  15Comments  路  Source: microsoft/vscode-cmake-tools

[[Thanks for your contribution! To make things easier, please fill out the template below, and delete any text marked in double square brackets.]]

[[If you have a question/suggestion/issue that doesn't fit this template,
feel free to delete the template and write any free text.]]

[[Please delete any unused sections.]]

Brief Issue Summary

Build stops when compiling c++ projects.
When I run ninja in gnome-terminal, it works well.

After last update of cmake-tools / vscode, I cannot build my project.
It seems to be build process going well, but after some time there's no new build logs.
There is no compiler (cc1plus) and cmake process exist at that moment.

[[For behavioral issues and feature requests/enhancements, use a list of
steps to describe the problem or suggested behavior. For example:]]

I cannot give you my source code because it is company property. But I can give you verbose logs from vscode:

[30073:0416/180208.721257:INFO:CONSOLE(2870)] "Error: Illegal argument: character must be non-negative
at Object.t.illegalArgument (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:86:833)
at new e (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:421:265)
at new e (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:423:486)
at CompileOutputConsumer.error (/home/dduk/.vscode/extensions/vector-of-bool.cmake-tools-0.11.0/out/src/diagnostics.js:252:35)
at CompileOutputConsumer.output (/home/dduk/.vscode/extensions/vector-of-bool.cmake-tools-0.11.0/out/src/diagnostics.js:290:25)
at CMakeBuildConsumer.output (/home/dduk/.vscode/extensions/vector-of-bool.cmake-tools-0.11.0/out/src/diagnostics.js:359:30)
at Socket.child.stdout.on (/home/dduk/.vscode/extensions/vector-of-bool.cmake-tools-0.11.0/out/src/proc.js:55:36)
at emitOne (events.js:96:13)
at Socket.emit (events.js:191:7)
at readableAddChunk (_stream_readable.js:178:18)
at Socket.Readable.push (_stream_readable.js:136:10)
at Pipe.onread (net.js:560:20)", source: file:///usr/share/code/resources/app/out/vs/workbench/workbench.main.js (2870)
[30073:0416/180208.726079:INFO:CONSOLE(2870)] "[vector-of-bool.cmake-tools]Illegal argument: character must be non-negative", source: file:///usr/share/code/resources/app/out/vs/workbench/workbench.main.js (2870)
[30073:0416/180208.726130:INFO:CONSOLE(2870)] "Error: Illegal argument: character must be non-negative
at Object.t.illegalArgument (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:86:833)
at new e (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:421:265)
at new e (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:423:486)
at CompileOutputConsumer.error (/home/dduk/.vscode/extensions/vector-of-bool.cmake-tools-0.11.0/out/src/diagnostics.js:252:35)
at CompileOutputConsumer.output (/home/dduk/.vscode/extensions/vector-of-bool.cmake-tools-0.11.0/out/src/diagnostics.js:290:25)
at CMakeBuildConsumer.output (/home/dduk/.vscode/extensions/vector-of-bool.cmake-tools-0.11.0/out/src/diagnostics.js:359:30)
at ChildProcess.child.on.retc (/home/dduk/.vscode/extensions/vector-of-bool.cmake-tools-0.11.0/out/src/proc.js:85:32)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:194:7)
at maybeClose (internal/child_process.js:899:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)", source: file:///usr/share/code/resources/app/out/vs/workbench/workbench.main.js (2870)
[30073:0416/180208.770825:INFO:CONSOLE(260)] "%c[IPC Library: Watcher] %c >> normalized", source: file:///usr/share/code/resources/app/out/vs/workbench/workbench.main.js (260)
[30073:0416/180216.686256:INFO:CONSOLE(1305)] "%cTRACE", source: file:///usr/share/code/resources/app/out/vs/workbench/workbench.main.js (1305)

Platform and Versions

[[For issues, fill out the following. Otherwise delete this section.]]

  • Operating System: Debian Stretch x64
  • CMake Version: 3.7.2
  • VSCode Version: 1.22.2, 3aeede733d9a3098f7b4bdc1f66b63b0f48c1ef9, x64
  • CMake Tools Extension Version: 0.11.0
  • Compiler/Toolchain: gcc 6.3
bug

All 15 comments

Thanks for the report. I can't quite see what's going wrong. Could you create a minimal reproduction of the issue that you could share?

I cannot give you my project repository but give you some hints:

Here's a part of my build output.

[build] [8/71] ....
[build] [9/71] ....
[build] [10/71] Building CXX object SubDir/SubLib/CMakeFiles/SubLib.dir/SubLib_unity.cpp.o

Build process seems going well until [10/71] but after that no build log is producing.

And..

  • At that point, there's error in vscode developer console.
    : "Error: Illegal argument: character must be non-negative"

  • When I try to build my project again, vscode tells "A CMake task is already running. Stop it before trying to configure" and no build task is starting.
    : But there's no running tasks (checked with "Tasks : Show Running Tasks" from command pallete)

I guess CMake task is not closing properly in some situation. To reproduce this error, I set up example project but failed to reproduce with this one.

Like I said, I cannot give you the project causing thie issue. However I can describe that.

  • Uses 50+ subprojects
  • To speed up build, uses "unity build" (.cpp files includes other .cpp files)
  • Uses ninja build system
  • Uses ccache

thank you.

I have a hypothesis: When you build the project from an external command line, how many lines of output are produced? There was an earlier issue in the project where a huge amount of output would cause the build process to lock up.

My project has 552 source files and number of lines of output is : 1,869.

FYI, I use Ninja as build system. (Ninja buffers build output)

Those ~2K lines might cause the issue. I'll look into bringing back an old work-around.

I have quite the same issue when using CMake (Unix Makefiles).

My environment:

  • Operating System: Lubuntu 16.04
  • CMake Version: 3.11.1
  • VSCode Version: 1.22.2, 3aeede733d9a3098f7b4bdc1f66b63b0f48c1ef9, x64
  • CMake Tools Extension Version: 0.11.1
  • Compiler/Toolchain: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609

Everything works fine until I add the following line to the CMakeLists.txt file:
set_property(SOURCE ${SOURCES} PROPERTY COMPILE_FLAGS ${CXX_WARNING_FLAGS})

  • With this I put additional compiler flags to a certain set of the source files.
  • I guess this causes CMake (Make) to do more things in parallel.

The end result is that CMake-Tools extension doesn't seem to get indication that the build is done.
The following log output is missing: [build] Build finished with exit code 0 , the extension is stuck and the taskbar is showing progress bar at 100%. The X Stop button does nothing and when trying to rebuild, I get that same error message "A CMake task is already running. Stop it before trying to configure"

The project builds fine with CMake from the terminal.

Adding warning flags? Sounds like you're causing more output in the panel, a similar possible cause. How many lines of output does your build produce with those warning flags set?

Lines of output:

  • Without warning flags: 38
  • With warning flags: 288

Project contains 33 source files being compiled.

However, in my case it doesn't seem to be related to the number of output lines produced.
I did the following test:

  • Still setting the compiler warning flags (-Wall -Wconversion) but removing the -Wextra (which produced 288 output lines) for a specific set of files.
  • Now the amount of output lines are 38 and it still get stuck at 100% i.e. not noticing that the build finished.
  • Further, adding the warnings to CMAKE_CXX_FLAGS variable i.e. all files is compiled with same set of options (not separately specifying any flags with set_property()), produces the same situation. If I remove the warning flags from the variable, then it works without any problems.

If you can think of any workaround, I would be happy to test it out.

Could you by chance create a minimal reproduction case?

Unfortunately I cannot send the failing project to you as it's company proprietary code.
I have tried to get the same behavior on other projects but with no success...
The exact same setup (CMakeLists.txt) for another project (with less sources) are working just fine.

Here's some exerts from the log:

With the property flag setting removed (ok case):
2018-05-02T12:37:00.620Z [info] [build] [100%] Built target ia_camera_relay
2018-05-02T12:37:00.628Z [info] [build] Build finished with exit code 0
2018-05-02T12:37:00.628Z [debug] [extension] [2611] cmake.build finished (returned 0)

With the property flag set (fail case):
2018-05-02T12:38:10.036Z [info] [build] [100%] Built target ia_camera_relay

Correction to my earlier comment, when the extension is "stuck" at 100% the Stop button do work, it doesn't remove the progress bar but I can rerun the CMake build again after pressing it. The following log output is generated when pressing that button:
2018-05-02T12:47:04.043Z [debug] [extension] [2031] cmake.stop started
2018-05-02T12:47:04.052Z [debug] [extension] [2031] cmake.stop finished (returned true)

Is there any chance you could run the extension in a debugger and try to work this out? If not, I can try to find a reproduction of the issue. I still think it is related to output being too much.

I debugged the extension and I think I found out why it fails in my case.

Part of the output from CMake in my build setup when reporting a warning:
/opt/pleora/ebus_sdk/Ubuntu-x86_64/include/PvGenICamLib.h:66:0: warning: ignoring #pragma comment [-Wunknown-pragmas]

proc.js

  • On line 71 it tries to output the stderr lines

diagnostics.js

  • Line 245: divides up the line using RegEx groups. Here column gets value '0'
  • Line 252: create a new vscode.Range, here parseInt(column) - 1 results in value = -1 which causes the Range to throw an exception.

This causes the Promise (proc.js:43) to never complete and the aync wait (driver.js:580) to never fire and therefore the extension will not exit the build.

I removed the -1 from the parseInt(column) on line 252 as a workaround and now the build exits nicely.
Also the warnings are listed in the Problems tab :+1: Although, the column is now off by one...

Excellent find! I can add a test case for this and all.

I'm curious about the line numbers though... I have to do that arithmetic because VSCode stores its line numbers in a different way than some compilers emit. Does the warning pragma actually appear on the first line?

I didn't include the whole output from the build. The warning line was just the first line to match the GCC compiler RegEx and cause this problem.

Before the line about the pragma warning, there was 5-6 lines showing the "call stack" i.e. through which files it goes before hitting the file causing the warning message.
After that it showed the actual "offending" line causing the warning and on the last line the caret (^) referring to the column location.

I'm not sure why gcc is using 0 for the first character (column) on the line (instead of 1).

This should be fixed in the next release. Thanks for the help.

Was this page helpful?
0 / 5 - 0 ratings