Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ASAN and TSAN integration testing #3343

Merged
merged 2 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,59 @@ jobs:
ctest --output-on-failure &&
cd ../Test && ./runtests

linux-asan:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
compiler: [{cc: gcc, cxx: g++}]
cmake_build_type: [Debug]
flags: ['-fsanitize=address', '-fsanitize=thread']
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: lukka/get-cmake@4dcd3eb73017c61159eb130746fbca35d78a3d5f # v3.27.4
- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version: '3.7'
- name: Setup ccache
uses: hendrikmuhs/ccache-action@6d1841ec156c39a52b1b23a810da917ab98da1f4 # v1.2.10
with:
key: ubuntu-22-${{ matrix.cmake_build_type }}-${{ matrix.compiler.cc }}-${{matrix.compiler.cxx}}-${{matrix.flags}}
- name: Install GoogleTest
run: |
# check out pre-breakage version of googletest; can be deleted when
# issue 3128 is fixed
# git clone --depth=1 https://github.com/google/googletest.git External/googletest
mkdir -p External/googletest
cd External/googletest
git init
git remote add origin https://github.com/google/googletest.git
git fetch --depth 1 origin 0c400f67fcf305869c5fb113dd296eca266c9725
git reset --hard FETCH_HEAD
cd ../..
- name: Update Glslang Sources
run: ./update_glslang_sources.py
- name: Configure
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }}
env:
CC: ${{matrix.compiler.cc}}
CXX: ${{matrix.compiler.cxx}}
CMAKE_GENERATOR: Ninja
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache
CFLAGS: ${{matrix.flags}}
CXXFLAGS: ${{matrix.flags}}
LDFLAGS: ${{matrix.flags}}
- name: Build
run: cmake --build build
- name: Install
run: cmake --install build --prefix build/install
- name: Test
run: |
cd build
ctest --output-on-failure &&
cd ../Test && ./runtests

# Ensure we can compile/run on an older distro
linux_min:
name: Linux Backcompat
Expand Down
31 changes: 19 additions & 12 deletions StandAlone/StandAlone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@
#include "../SPIRV/doc.h"
#include "../SPIRV/disassemble.h"

#include <cstring>
#include <cstdlib>
#include <array>
#include <atomic>
#include <cctype>
#include <cmath>
#include <array>
#include <cstdlib>
#include <cstring>
#include <map>
#include <memory>
#include <thread>
#include <set>
#include <thread>

#include "../glslang/OSDependent/osinclude.h"

Expand Down Expand Up @@ -144,8 +145,9 @@ void FreeFileData(char* data);
void InfoLogMsg(const char* msg, const char* name, const int num);

// Globally track if any compile or link failure.
bool CompileFailed = false;
bool LinkFailed = false;
std::atomic<int8_t> CompileFailed{0};
arcady-lunarg marked this conversation as resolved.
Show resolved Hide resolved
std::atomic<int8_t> LinkFailed{0};
std::atomic<int8_t> CompileOrLinkFailed{0};

// array of unique places to leave the shader names and infologs for the asynchronous compiles
std::vector<std::unique_ptr<glslang::TWorkItem>> WorkItems;
Expand Down Expand Up @@ -1166,6 +1168,7 @@ void CompileShaders(glslang::TWorklist& worklist)
if (Options & EOptionDebug)
Error("cannot generate debug information unless linking to generate code");

// NOTE: TWorkList::remove is thread-safe
glslang::TWorkItem* workItem;
if (Options & EOptionStdin) {
if (worklist.remove(workItem)) {
Expand Down Expand Up @@ -1442,15 +1445,15 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
if (shader->preprocess(GetResources(), defaultVersion, ENoProfile, false, false, messages, &str, includer)) {
PutsIfNonEmpty(str.c_str());
} else {
CompileFailed = true;
CompileFailed = 1;
}
StderrIfNonEmpty(shader->getInfoLog());
StderrIfNonEmpty(shader->getInfoDebugLog());
continue;
}

if (! shader->parse(GetResources(), defaultVersion, false, messages, includer))
CompileFailed = true;
CompileFailed = 1;

if (!compileOnly)
program.addShader(shader);
Expand Down Expand Up @@ -1496,7 +1499,9 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)

// Dump SPIR-V
if (Options & EOptionSpv) {
if (CompileFailed || LinkFailed)
CompileOrLinkFailed.fetch_or(CompileFailed);
CompileOrLinkFailed.fetch_or(LinkFailed);
if (static_cast<bool>(CompileOrLinkFailed.load()))
printf("SPIR-V is not generated for failed compile or link\n");
else {
std::vector<glslang::TIntermediate*> intermediates;
Expand Down Expand Up @@ -1555,7 +1560,9 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
}
}

if (depencyFileName && !(CompileFailed || LinkFailed)) {
CompileOrLinkFailed.fetch_or(CompileFailed);
CompileOrLinkFailed.fetch_or(LinkFailed);
if (depencyFileName && !static_cast<bool>(CompileOrLinkFailed.load())) {
std::set<std::string> includedFiles = includer.getIncludedFiles();
sources.insert(sources.end(), includedFiles.begin(), includedFiles.end());

Expand Down Expand Up @@ -1731,9 +1738,9 @@ int singleMain()
ShFinalize();
}

if (CompileFailed)
if (CompileFailed.load())
return EFailCompile;
if (LinkFailed)
if (LinkFailed.load())
return EFailLink;

return 0;
Expand Down