Cannot find path for the handle.The handle is invalid.

Sep 5, 2016 at 9:49 AM
I'm using a CI workflow with Jenkins.

A bat file is generated at the end of every compilation, which looks like this:
OpenCppCoverage -q --continue_after_cpp_exception  --sources D:\Jenkins\workspace\bfsearch --modules D:\Jenkins\workspace\bfsearch  --excluded_sources D:\Jenkins\workspace\bfsearch\tests  --excluded_sources D:\Jenkins\workspace\bfsearch\bin  --export_type=binary:coverage_results_bfs_add_test_TESTTARGET.exe.cov -- D:\Jenkins\workspace\bfsearch\bin\tests\Debug\bfs_add_test_TESTTARGET.exe
OpenCppCoverage -q --continue_after_cpp_exception  --sources D:\Jenkins\workspace\bfsearch --modules D:\Jenkins\workspace\bfsearch  --excluded_sources D:\Jenkins\workspace\bfsearch\tests  --excluded_sources D:\Jenkins\workspace\bfsearch\bin  --export_type=binary:coverage_results_bfs_cluster_around_center_tests_TESTTARGET.exe.cov -- D:\Jenkins\workspace\bfsearch\bin\tests\Debug\bfs_cluster_around_center_tests_TESTTARGET.exe
OpenCppCoverage -q --continue_after_cpp_exception  --sources D:\Jenkins\workspace\bfsearch --modules D:\Jenkins\workspace\bfsearch  --excluded_sources D:\Jenkins\workspace\bfsearch\tests  --excluded_sources D:\Jenkins\workspace\bfsearch\bin  --export_type=binary:coverage_results_bfs_multiple_cluster_centers_test_TESTTARGET.exe.cov -- D:\Jenkins\workspace\bfsearch\bin\tests\Debug\bfs_multiple_cluster_centers_test_TESTTARGET.exe
OpenCppCoverage -q --continue_after_cpp_exception  --sources D:\Jenkins\workspace\bfsearch --modules D:\Jenkins\workspace\bfsearch  --excluded_sources D:\Jenkins\workspace\bfsearch\tests  --excluded_sources D:\Jenkins\workspace\bfsearch\bin --input_coverage=coverage_results_bfs_add_test_TESTTARGET.exe.cov --input_coverage=coverage_results_bfs_cluster_around_center_tests_TESTTARGET.exe.cov --input_coverage=coverage_results_bfs_multiple_cluster_centers_test_TESTTARGET.exe.cov  --export_type=cobertura:coverage_results.xml -- D:\Jenkins\workspace\bfsearch\bin\tests\Debug\bfs_radius_test_TESTTARGET.exe
My test runs always fail due to an unambiguous bug in opencppcoverage:
Error: HandleInformation.cpp:85 Cannot find path for the handle.The handle is invalid.

D:\Jenkins\workspace\bfsearch>./runtests.bat

D:\Jenkins\workspace\bfsearch>OpenCppCoverage -q --continue_after_cpp_exception  --sources D:\Jenkins\workspace\bfsearch --modules D:\Jenkins\workspace\bfsearch  --excluded_sources D:\Jenkins\workspace\bfsearch\\tests  --excluded_sources D:\Jenkins\workspace\bfsearch\\bin  --export_type=binary:coverage_results_bfs_add_test_TESTTARGET.exe.cov -- D:\Jenkins\workspace\bfsearch\bin\tests\Debug\bfs_add_test_TESTTARGET.exe 
Error: HandleInformation.cpp:85 Cannot find path for the handle.The handle is invalid.



D:\Jenkins\workspace\bfsearch>OpenCppCoverage -q --continue_after_cpp_exception  --sources D:\Jenkins\workspace\bfsearch --modules D:\Jenkins\workspace\bfsearch  --excluded_sources D:\Jenkins\workspace\bfsearch\\tests  --excluded_sources D:\Jenkins\workspace\bfsearch\\bin  --export_type=binary:coverage_results_bfs_cluster_around_center_tests_TESTTARGET.exe.cov -- D:\Jenkins\workspace\bfsearch\bin\tests\Debug\bfs_cluster_around_center_tests_TESTTARGET.exe 
Error: HandleInformation.cpp:85 Cannot find path for the handle.The handle is invalid.



D:\Jenkins\workspace\bfsearch>OpenCppCoverage -q --continue_after_cpp_exception  --sources D:\Jenkins\workspace\bfsearch --modules D:\Jenkins\workspace\bfsearch  --excluded_sources D:\Jenkins\workspace\bfsearch\\tests  --excluded_sources D:\Jenkins\workspace\bfsearch\\bin  --export_type=binary:coverage_results_bfs_multiple_cluster_centers_test_TESTTARGET.exe.cov -- D:\Jenkins\workspace\bfsearch\bin\tests\Debug\bfs_multiple_cluster_centers_test_TESTTARGET.exe 
Error: HandleInformation.cpp:85 Cannot find path for the handle.The handle is invalid.



D:\Jenkins\workspace\bfsearch>OpenCppCoverage -q --continue_after_cpp_exception  --sources D:\Jenkins\workspace\bfsearch --modules D:\Jenkins\workspace\bfsearch  --excluded_sources D:\Jenkins\workspace\bfsearch\\tests  --excluded_sources D:\Jenkins\workspace\bfsearch\\bin --input_coverage=coverage_results_bfs_add_test_TESTTARGET.exe.cov --input_coverage=coverage_results_bfs_cluster_around_center_tests_TESTTARGET.exe.cov --input_coverage=coverage_results_bfs_multiple_cluster_centers_test_TESTTARGET.exe.cov  --export_type=cobertura:coverage_results.xml -- D:\Jenkins\workspace\bfsearch\bin\tests\Debug\bfs_radius_test_TESTTARGET.exe 
Argument of input_coverage <coverage_results_bfs_add_test_TESTTARGET.exe.cov> does not exist.
OpenCppCoverage Version: 0.9.5.2

Usage: [options] -- program_to_run optional_arguments:

Command line only:
  -v [ --verbose ]                 Verbose mode.
  -q [ --quiet ]                   Quiet mode.
  -h [ --help ]                    Show help message.
  --config_file arg                Filename of a configuration file.

Command line and configuration file:
  --modules arg (=*)               The pattern that module's paths should 
                                   match. Can have multiple occurrences.
  --excluded_modules arg           The pattern that module's paths should NOT 
                                   match. Can have multiple occurrences.
  --sources arg (=*)               The pattern that source's paths should 
                                   match. Can have multiple occurrences.
  --excluded_sources arg           The pattern that source's paths should NOT 
                                   match. Can have multiple occurrences.
  --input_coverage arg             A output path of export_type=binary. This 
                                   coverage data will be merged with the 
                                   current one. Can have multiple occurrences.
  --export_type arg (=html)        Format: <exportType>:<outputPath>.
                                   <exportType> can be: binary, cobertura, html
                                   <outputPath> (optional) output file or 
                                   directory for the export.
                                   Example: html:MyFolder\MySubFolder
                                   This flag can have multiple occurrences.
  --working_dir arg                The program working directory.
  --cover_children                 Enable code coverage for children processes.
  --no_aggregate_by_file           Do not aggregate coverage for same file 
                                   path.
  --unified_diff arg               Format: <unifiedDiffPath>?<rootFolder>
                                   <unifiedDiffPath> path of the unified diff 
                                   file. Git users can use git diff output.
                                   <rootFolder> (optional) root folder for 
                                   paths in the diff file.
                                   See documentation for limitations.
  --continue_after_cpp_exception   Try to continue after throwing a C++ 
                                   exception.

Build step 'Execute Windows batch command' marked build as failure
Skipping Cobertura coverage report as build was not UNSTABLE or better ...
Can you help me with this? The same script was working a month ago, now it doesn't. Is there something related to windows updates ? I've also looked at the source code, there's no such code at HandleInformation.cpp:85 that can cause an error like that. Is source code updated in the repository?

Best,
Onat
Coordinator
Sep 6, 2016 at 12:46 PM
Hello,

If you want to see the latest code you need to select release 0.9 branch (and not master).
When an executable load a dll, the method GetFinalPathNameByHandle is called with the dll handle to get the full path. For unkkown reason, this method return an errorin your case.

Can you try to create a small project and check if you have the problem? If yes we need to look at your operating / environment changes.
Do you have an antivirus software? If yes can you try to temporary disable?
Does resintalling OpenCppCoverage help?

Let me know if you find something,

OpenCppCoverage
Sep 7, 2016 at 7:10 AM
Hello.

I've installed the latest version, the problem persists.

Here's a quick project I've created to test the issue.

https://github.com/onatbas/OpenCppCoverageTestFail

I've included the verbose output for you.

I'm running Windws 7 x64.
I don't have any antivirus software.

Best,
Onat
Coordinator
Sep 8, 2016 at 4:24 PM
Hello,

I would like to thanks for your link, this is a big help for understanding your problem!
I tried exactly the steps you described but I was available to create the coverage with any issue on Windows 10.

I have just noticed your issue looks like this one.
Are your sources located in a ClearCase view or a network drive?

If not, I will try to test OpenCppCoverageTestFail on Windows 7.

I hope this will help,

OpenCppCoverage
Oct 25, 2016 at 7:48 AM
Edited Oct 25, 2016 at 7:50 AM
They're in the same folder, a single drive that is.

I have moved this thread to stack overflow in hope that someone might have a lead on it.

http://stackoverflow.com/questions/40233115/opencppcoverage-cannot-find-path-for-the-handle
Coordinator
Nov 2, 2016 at 11:38 PM
Hello,

I cloned your code https://github.com/onatbas/OpenCppCoverageTestFail again. I was able to run OpenCppCoverage without any issue on Window 7 x86 (Cannot test on x64).

It seems you cannot even run a basic application. Can you try the following things?
  • uninstall previous installations of OpenCppCoverage
  • Create a Visual Studio default console application
  • Install the latest version of OpenCppCoverage (x64 and x86)
  • Run both versions of OpenCppCoverage on the console application in Debug / Win32
If you still have the same problem, can you test on another computer/ operating system?

If nothing works, please let me know and I will sent you a simplified version of the code so that you can investigate on your side.

I hope this will help,

OpenCppCoverage
Coordinator
Jan 25 at 10:21 PM
Hello,

I did a simplified version of what OpenCppCoverage does here.
Can you try to run it on your project?

GetFinalPathNameByHandle should fail. If you are able to reproduce the issue, can you try to investigate why it fails or if you can find a way to reproduce the problem?

I hope it will help,

OpenCppCoverage