JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
General

Troubleshooting the Build

This section provides solutions for problems you may encounter during the CodeSonar build/analysis process.

In this section (and throughout this manual), $CSONAR indicates the CodeSonar installation directory.

Problems

General Problems

C and C++

Java

C#

Windows Build Wizard Problems [Windows only]

Command Line Build Problems

Solutions

General

The CodeSonar system overwrote some of my files.
When you run CodeSonar on your code several files are written in the target directory. Make sure your choice of CodeSonar pfiles-name does not cause name conflicts with any of your existing files.
The build/analysis seems to be stuck, but there is no notification of any problems.

There are several possibilities.

The build/analysis command is failing with the message
[...]
Failed to initialize hub communications.
or
[...]
Failed to open connection to hub interface:port
There are several situations in which CodeSonar will be unable to establish communication with the hub location specified (via interface:port) in your build command. The most common are shown in the table below.
Problem Action
There is no hub running at the specified location. Either
  • start a hub at the location, or
  • specify a different hub location in your build/analysis command.
There is a hub running at the specified location, but your build/analysis cannot connect to it using IPv6.
(This may occur on legacy operating systems.)
See FAQ: How do I specify that the build/analysis should communicate with the hub using IPv4 only?
There is a hub running on the indicated machine, but it is not listening on the interface specified in your build command. Either
There is a hub listening on the interface specified in your build command, but a firewall is preventing access. See FAQ: How do I allow hub access through a firewall?
I'm using Bazel and CodeSonar isn't recognizing some of my compilations.
Make sure your Bazel build is configured so that all compilations are visible to CodeSonar. In particular:
[Windows only] I'm invoking the CodeSonar build/analysis inside a container running Windows, and it is failing with a message like "Couldn't initialize the interception device driver".
This occurs because Windows containers cannot host minifilter drivers, such as the one that implements virtual compiler proxying.

To resolve this, do the following.

  1. Set VIRTUAL_COMPILER_PROXY=No in the project configuration file.
  2. In your container, manually rename your compiler executables and then make a copy of our proxy (%CSONAR%\codesonar\bin\spawncs_userland.exe) where the compiler executable used to be.

    For a compiler executable named compilername.exe, the renamed file must be named compilername.orig.exe.

    For example:

    rename cl.exe cl.orig.exe
    copy "c:\Program Files\CodeSecure\CodeSonar\codesonar\bin\spawncs_userland.exe" cl.exe
    
[Windows only] The build (and possibly other parts of the OS) hangs, attempts to kill spawncs.exe fail, and rebooting is impossible except by pressing the computer's power button.
This problem has been observed on machines running Symantec Endpoint Protection versions 12.0 through 12.1.4xxx.xxx, and is due to an issue with that product. Symantec fixed the issue in version 12 RU5 (12.1.5xxx).

For versions that have this problem, Symantec's recommended workaround is to uninstall the "Application and Device Control" component of Symantec Endpoint Protection:

  1. Open the Control Panel.
  2. Open the Programs and Features dialog.
    (Called Add/Remove Programs in older versions of Windows.)
  3. Right click Symantec Endpoint Protection
  4. Click Change.
    The Symantec Endpoint Protection installation wizard will open.
  5. Click Next.
  6. Select Modify and click Next.
  7. Expand Proactive Threat Protection by clicking the + sign next to it.
  8. Click the disk icon next to Application and Device Control.
  9. Select Entire Feature will be unavailable.
  10. Click Next as needed to effect the change.

C and C++

I am getting errors because my includes are not found or macros are not defined.
Edit the CFLAGS_PREPEND and CFLAGS_APPEND parameter settings in the configuration file to pass any needed flags to the compiler.
The CodeSonar build isn't working because I need to customize CodeSonar's compiler command line processing beyond that already provided for in the built-in compiler models.
You can author a CodeSonar Compiler Model.
The build does not seem to notice the compiler invocations.
The most common cause of this problem is that the compiler is not recognized by CodeSonar. Configure CodeSonar to recognize your compiler(s) using the instructions in section Mapping Compiler Names to Models.

If CodeSonar is configured to recognize your compiler compiler_name.exe and the build still does not seem to be recognizing the compilations:

Code generated during my project's normal compilation is not being analyzed.
If your normal compilation includes a compiler process that generates source code and then compiles it, you will need to make sure this process executes before the project analysis begins. To do this, set INVOKE_COMPILER_FIRST=Yes in the project configuration file.
I am getting a CodeSonar parse error and the Parse Log says that the template instantiation stack is too deep.
This indicates that you have one or more templates that are recursively instantiated with a deeper recursion depth than the current limit.

To resolve this, use front end option --pending_instantiations to set a higher bound on the number of instantiations of a given template that may be pending at a time. Try setting to 256 first, then increasing in powers of 2 until the parse error is resolved. If you reach 4096 without resolving the parse error, it is worth making sure that the code really should use such a deep instantiation stack before increasing further.

I wrote a custom STk compiler model and it is no longer being recognized.
STk compiler models are no longer supported. If you have previously implemented a custom STk compiler model and need assistance converting it to C++ or Python, contact CodeSecure.

Windows Build Wizard [Windows only]

I'm ready to click the Finalize button, but it's greyed out.
This occurs when CodeSonar hasn't observed any compilations yet. There are two possible causes.
I'm using Microsoft Visual Studio, and there are a lot of errors in my CodeSonar build log.
This is likely caused by having "precompiled headers" enabled. In general it is best to disable precompiled headers.
The builder causes unusual behavior in other programs (such as crashing).
This may be a result of antivirus/antispyware software running on your computer (the builder must spy on your regular build processes in order to generate the project). Disable the software while you are running CodeSonar.
The Build Wizard window is too small to show all the contents and I can't resize it.
This can occur if Windows screen resolution has been changed since Windows was installed.

To resolve:

  1. Check registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts, finding the entries for Courier, MS Serif and MS Sans Serif. There may be additional numbers in the font titles.
  2. Change the settings for entries to COURE.FON, SERIFE.FON, and SSERIFE.FON, respectively.
  3. Sign out of Windows, then sign back in.

Command Line

The build/analysis command is failing with a message like
(Fedora Core 9)
libX11.so.6: cannot open shared object file
(Ubuntu 9.04)
No such file or directory
This can indicate that 32-bit libraries, which are required by CodeSonar, are not installed. Consult your system administrator to arrange installation.
The build/analysis command is failing with the message
The project appears to be empty; no files have been compiled.
CodeSonar is not recognizing the compilations carried out by your build command. Configure CodeSonar to recognize your compiler(s) using the instructions in section Mapping Compiler Names to Models.
The build/analysis is failing with a message like
CreateProcess failed: 2: The system cannot find the file specified.
Cannot launch "cmd"
codesonar: 'cmd' exited with 888.
(where cmd is the usual software build command)
This occurs when CodeSonar doesn't recognize your build command.
The build/analysis is failing with a message like
Cannot launch "cmd"
codesonar: 'cmd' exited with 65280.
(where cmd is the usual software build command)
This occurs when CodeSonar does not have permission to execute cmd. Change the settings on cmd so that CodeSonar is able to execute it.
The build/analysis is failing with a message like
codesonar: I tried to exec 'scriptname', but it didn't work: 8: Exec format error
[...]
Please check whether 'scriptname' is missing or has a malformed "#! /bin/sh" header (or similar), if it is supposed to be interpreted. Some shells will let you get away with omitting it. If the #! fix does not resolve this problem, then contact CodeSecure support
codesonar: 'cmd exited with 512.
(where cmd is the usual software build command, and it executes scriptname)
This occurs when your compiler is interpreted (for example a shell script, Python script, Perl script, or AWK script) but does not start with an interpreter line (#!). In these cases, CodeSonar cannot determine how to interpret the compiler.

To fix the problem, modify scriptname to start with an interpreter line of the form

#! interpreter-specific content

For more information, see web search results for shebang+line.

The build/analysis is failing with a message like
ERROR: ld.so: object '(The path to codesonar)/csurf/lib/ libhookcs.so' from LD_PRELOAD cannot be preloaded: ignored
Check that you have installed the correct CodeSonar package for your system. On 64-bit Linux systems, the correct package is labeled x86_64-pc-linux — this message has been observed when the i686-pc-linux package was installed instead.
 

To report problems with this documentation, please visit https://support.codesecure.com/.