microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.44k stars 435 forks source link

C++ Build stops in last update of vscode #387

Closed KuddLim closed 6 years ago

KuddLim commented 6 years ago

[[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.]]

vector-of-bool commented 6 years ago

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?

KuddLim commented 6 years ago

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..

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.

thank you.

vector-of-bool commented 6 years ago

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.

KuddLim commented 6 years ago

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)

vector-of-bool commented 6 years ago

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

ghost commented 6 years ago

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

My environment:

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

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.

vector-of-bool commented 6 years ago

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?

ghost commented 6 years ago

Lines of output:

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:

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

vector-of-bool commented 6 years ago

Could you by chance create a minimal reproduction case?

ghost commented 6 years ago

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)

vector-of-bool commented 6 years ago

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.

ghost commented 6 years ago

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

diagnostics.js

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...

vector-of-bool commented 6 years ago

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?

ghost commented 6 years ago

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).

vector-of-bool commented 6 years ago

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