vscode-cmake-tools
vscode-cmake-tools copied to clipboard
[Bug] Build hangs on 1.21.17 pre-release
Brief Issue Summary
When using a premade NXP sdk example, i used the all toolchains version of the MIMXRT1064 sdk, version 25.03. the build hangs and never completes. I think this demo repo should show the bug correctly, if there is any problem in the setup process let me know so i can help Bug showcase repo With the current release of the extension the build fails, it is expected behavior. With the pre-release it doesnt even really start... it just sort of hangs from the beginning.
CMake Tools Diagnostics
{
"os": "win32",
"vscodeVersion": "1.99.3",
"cmtVersion": "1.21.17",
"configurations": [
{
"folder": "c:\\Git\\Testing\\evkmimxrt1064_freertos_hello",
"cmakeVersion": "3.31.5",
"configured": true,
"generator": "Ninja",
"usesPresets": true,
"compilers": {
"C": "",
"CXX": ""
}
}
],
"cpptoolsIntegration": {
"isReady": false,
"hasCodeModel": false,
"activeBuildType": "",
"buildTypesSeen": [],
"requests": [],
"responses": [],
"partialMatches": [],
"targetCount": 0,
"executablesCount": 0,
"librariesCount": 0,
"targets": []
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "always",
"configureOnOpen": false
}
]
}
Debug Log
[main] Building folder: C:/Git/Testing/evkmimxrt1064_freertos_hello/armgcc/flexspi_nor_debug
[main] Saving open files before configure/build
[build] Starting build
[driver] Start build
[proc] Executing command: chcp
Additional Information
No response
Hi @PILIX123, thanks for reporting issue here!
After a series of installation and setup processes based on readme.md file, reproduced this issue on CMake Tool current pre-release v1.21.7, build hangs and never completes. And it doesn't repro on CMake Tool current release v1.20.53, issue starts repro from pre-release v1.21.4.
@gcampbell-msft FYI.
@Amy-Li03 I starts reproducing on 1.21.4? The version 1.21.4 only modifies strings, they don't modify any behavior. However, this change: https://github.com/microsoft/vscode-cmake-tools/commit/2006d330ee105474b24a74964dbf71e3f3d7eef3, was the change in version 1.21.0, and it's possible that introduced it.
@PILIX123 I wonder if you modify the cmake.parallelJobs setting to have a higher number, it's possible this will fix your issue. Could you try it out? Thanks
First and foremost i want to thank @Amy-Li03 for having gone through the repro steps. @gcampbell-msft and after testing increasing by 10x from 1 to 100000, there was no change in the behaviour
@Amy-Li03 I starts reproducing on 1.21.4? The version 1.21.4 only modifies strings, they don't modify any behavior. However, this change: 2006d33, was the change in version 1.21.0, and it's possible that introduced it.
@gcampbell-msft, on 1.21.4, build hangs; on 1.21.0, build successfully.
In addition, I found the behavior is a little different between version 1.21.4 and 1.21.5(behavior is same as latest 1.21.7), on version 1.21.4, when building, the Output window print below message and build will complete when clicking on Output window.
[rollbar] "sourceDirectory" is not a directory {"sourceDirectory":"/c:/Users/v-amyli3/Desktop/GHIssue/4424/cmake-bug-demo"}
[TaskProvider] Project not found.
on version 1.21.5, when building, no above message print on Output window.
After testing a little, the current way the bug is acting was introduced in 1.21.5, but there is the bug shown by @Amy-Li03 that starts in 1.21.4 and even if you select build it fails with the following log, but that behaviour is fixed by 1.21.5,
[main] Saving open files before configure/build
[main] The extension determined that a configuration is needed at this moment but we are skipping because the setting cmake.skipConfigureIfCachePresent is ON. Make sure the CMake cache is in sync with the latest configuration changes.
[build] Starting build
[driver] Start build
[rollbar] "sourceDirectory" is not a directory {"sourceDirectory":"/C:/Git/Testing/evkmimxrt1064_freertos_hello"}
[TaskProvider] Project not found.
[rollbar] "sourceDirectory" is not a directory {"sourceDirectory":"/C:/Git/Testing/evkmimxrt1064_freertos_hello"}
[TaskProvider] Project not found.
[rollbar] "sourceDirectory" is not a directory {"sourceDirectory":"/C:/Git/Testing/evkmimxrt1064_freertos_hello"}
[TaskProvider] Project not found.
[rollbar] "sourceDirectory" is not a directory {"sourceDirectory":"/C:/Git/Testing/evkmimxrt1064_freertos_hello"}
[TaskProvider] Project not found.
[rollbar] "sourceDirectory" is not a directory {"sourceDirectory":"/C:/Git/Testing/evkmimxrt1064_freertos_hello"}
[TaskProvider] Project not found.
[rollbar] "sourceDirectory" is not a directory {"sourceDirectory":"/C:/Git/Testing/evkmimxrt1064_freertos_hello"}
[TaskProvider] Project not found.
[rollbar] "sourceDirectory" is not a directory {"sourceDirectory":"/C:/Git/Testing/evkmimxrt1064_freertos_hello"}
[TaskProvider] Project not found.
[rollbar] "sourceDirectory" is not a directory {"sourceDirectory":"/C:/Git/Testing/evkmimxrt1064_freertos_hello"}
[TaskProvider] Project not found.
[rollbar] "sourceDirectory" is not a directory {"sourceDirectory":"/C:/Git/Testing/evkmimxrt1064_freertos_hello"}
[TaskProvider] Project not found.
[rollbar] "sourceDirectory" is not a directory {"sourceDirectory":"/C:/Git/Testing/evkmimxrt1064_freertos_hello"}
[TaskProvider] CMake Tools not found.
[driver] Build completed: 00:00:01.815
[cmakefileapi-parser] Read reply folder: C:\Git\Testing\evkmimxrt1064_freertos_hello\armgcc\flexspi_nor_debug\.cmake\api\v1\reply
[cmakefileapi-parser] Found index files: ["cache-v2-0abd4fdbd9e687ecef29.json","cmakeFiles-v1-1282920c5627464ae08f.json","codemodel-v2-46a0a5766e0055c7b2fb.json","directory-.-flexspi_nor_debug-d0094a50bb2071803777.json","index-2025-04-24T22-39-49-0760.json","target-freertos_hello.elf-flexspi_nor_debug-d07953a46aaaed7e0e0e.json","toolchains-v1-620b04c1766a76c7aa02.json"]
[extension] Not updating the configuration provider because "C_Cpp.intelliSenseEngine" is set to "Disabled"
[build] Build finished with exit code 0
[extension] [9216] cmake.build finished (returned 0)
more testing later the current bug was introduced in https://github.com/microsoft/vscode-cmake-tools/commit/d2dc0ed5da77d783ef4aabdd5b50721f8c8b974c i havent diagnosed why it was introduced the commit is too large for me. i diagnosed this by doing the fix in https://github.com/microsoft/vscode-cmake-tools/commit/0b7053d14bb0efc2e577a120a32edc95fc159030 and testing if the bug was getting reproduced, and it did.
@PILIX123 I have marked this for the next release, and I will work on it as soon as I can, thanks. Is there any way that you could reproduce this without the complex project?
I can try to do so.
@gcampbell-msft i didnt manage to get a smaller repro project, but i analyzed the code and debugged a little, the problem has to do with this https://github.com/microsoft/vscode-cmake-tools/blob/a1aa2c31780df25ae8c556da9b5f39e26765f624/src/cmakeTaskProvider.ts#L473-L476 because in this case this.workspaceFolder is not the expected structure. its just the number 2. I think its because at https://github.com/microsoft/vscode-cmake-tools/blob/a1aa2c31780df25ae8c556da9b5f39e26765f624/src/cmakeTaskProvider.ts#L284 we use vscode.TaskScope.Workspace which is an enum for the number 2.
looking at the commit history, this has been the case for 3 years, i dont know if this is the real cause of the error, but i guess that at line 473 we expect the type of this.workspaceFolder to be a vscode.WorkspaceFolder but it's a vscode.TaskScope.Workspace enum
and after moving https://github.com/microsoft/vscode-cmake-tools/blob/a1aa2c31780df25ae8c556da9b5f39e26765f624/src/cmakeTaskProvider.ts#L335-L339 from line 335 to line 260 and using the workspaceFolderObj instead of vscode.TaskScope.Workspace on line 284, now 291,
const buildTask: CMakeTask = new vscode.Task(definition, workspaceFolderObj, task.definition.label, CMakeTaskProvider.CMakeSourceStr);
the build doesnt fail anymore
Also, when checking on line 473 if the new project is the same as the old one i get true
let project: CMakeProject | undefined = getActiveProject();
if (this.workspaceFolder !== undefined) {
// this.writeEmitter.fire("Workspace is " + this.workspaceFolder.uri.path + endOfLine);
let t = await extensionManager?.getProjectForFolder(this.workspaceFolder);
project = t;
}
I don't really know what to do from here, but it's the most information i managed to gather
@PILIX123 THanks for the information! I think this is likely due to a recent change in this feature, and as you pointed out, it may have been an underlying bug for a long time that is finally now rearing its head.
It may have been introduced and/or modified enough for this bug to show from this commit.
Seeing as the changes you mentioned fixed the issue we'd be happy to take an open sourced contribution from you, pending review!
@gcampbell-msft I can look into making a PR, but what im wondering is, if it might break other things that were working properly because of this.
I opened a PR for it https://github.com/microsoft/vscode-cmake-tools/pull/4479
Verified on CMake Tools v1.21.31(pre-release), issue was fixed, build can be completed without hang, so close it.