CFamily Sonar Scanner raises an exception when scanning code

  • Versions used (SonarQube, Scanner, Plugin, and any relevant extension)

Sonar Scanner with the CFamily plugin:

  • build-wrapper, version 6.12 (linux-x86)
  • SonarScanner 4.4.0.2170
  • Java 11.0.3 AdoptOpenJDK (64-bit)
  • Linux 5.4.0-47-generic amd64
  • CMake 3.16
  • g++ 9.3, with std=c++17
  • Error observed
ERROR: 
An error occurred while analyzing the following compilation unit: 
  /***/***/microphone-service/src/microphoneservice.cpp
A file named "sonar-cfamily.reproducer" has been generated to help the problem investigation.
Please contact SonarSource support providing the following file to help improving the analyzer:
  /***/***/microphone-service/sonar-cfamily.reproducer

The same error is repeated for a number of other files. sonar-scanner.txt (12.2 KB) .

  • Steps to reproduce
    Please let me know the best way to provide sonar-cfamily.reproducer privately

  • Potential workaround

    • Add the files to the exclusion lists. This lets the scanner work on some files, but then not all files are getting scanned, so this is not ideal
  • Scanner command used when applicable (private details masked):
    Build wrapper run with: (build-sonar is clean CMake build directory)
    build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT make -j $(nproc) -C build-sonar clean all

Sonar scanner run with sonar-scanner using the following project properties:

sonar.projectKey=****
sonar.projectName=****
sonar.organization=****
sonar.sources=src
sonar.host.url=https://sonarcloud.io
sonar.cfamily.build-wrapper-output=sonar/bw-output
sonar.cfamily.junit.reportsPath=test-reports
sonar.sourceEncoding=UTF-8
sonar.cfamily.threads=8
  • In case of SonarCloud:
    • Bitbucket Cloud + Bitbucket Pipelines, but the error also exists when running the scanner manually

Hi @elenium,

I am sending you a private message where you can share safely.

Hi @elenium,

the analyzer crashes because of some boost codem we use Clang fronted as the core of our analyzer, in /usr/include/boost/asio/execution/blocking.hpp:324:42, note #if !defined(__clang__) // Clang crashes if noexcept is used here.:

  template <typename Executor>
  friend BOOST_ASIO_CONSTEXPR blocking_t query(
      const Executor& ex, convertible_from_blocking_t,
      typename enable_if<
        can_query<const Executor&, possibly_t>::value
      >::type* = 0)
#if !defined(__clang__) // Clang crashes if noexcept is used here.
#if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
    BOOST_ASIO_NOEXCEPT_IF((
      is_nothrow_query<const Executor&, blocking_t<>::possibly_t>::value))
#else // defined(BOOST_ASIO_MSVC)
    BOOST_ASIO_NOEXCEPT_IF((
      is_nothrow_query<const Executor&, possibly_t>::value))
#endif // defined(BOOST_ASIO_MSVC)
#endif // !defined(__clang__)
  {
    return boost::asio::query(ex, possibly_t());
  }

I created a ticket CPP-2696, the workaround to avoid the crash is to add -DBOOST_ASIO_DISABLE_NOEXCEPT to your build.

Thanks :+1:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.