Skip to content

Commit

Permalink
Merge pull request #118 from biojppm/ci/sanitize
Browse files Browse the repository at this point in the history
  • Loading branch information
biojppm committed May 27, 2023
2 parents 2332b5e + 882df8a commit 49435aa
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 75 deletions.
83 changes: 47 additions & 36 deletions .github/workflows/clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,27 +116,39 @@ jobs:
continue-on-error: true
if: always() # https://stackoverflow.com/questions/62045967/github-actions-is-there-a-way-to-continue-on-error-while-still-getting-correct
runs-on: ubuntu-latest
container: ghcr.io/biojppm/c4core/ubuntu18.04:latest # use the docker image
container: ghcr.io/biojppm/c4core/${{matrix.img}}:latest # use the docker image
strategy:
fail-fast: false
matrix:
include:
- {std: 20, cxx: clang++-10 , bt: Debug , vg: on}
- {std: 20, cxx: clang++-10 , bt: Release, vg: on}
- {std: 11, cxx: clang++-9 , bt: Debug , vg: on}
- {std: 11, cxx: clang++-9 , bt: Release, vg: on}
- {std: 11, cxx: clang++-8 , bt: Debug , vg: on}
- {std: 11, cxx: clang++-8 , bt: Release, vg: on}
- {std: 11, cxx: clang++-7 , bt: Debug , vg: on}
- {std: 11, cxx: clang++-7 , bt: Release, vg: on}
- {std: 11, cxx: clang++-6.0, bt: Debug , vg: on}
- {std: 11, cxx: clang++-6.0, bt: Release, vg: on}
- {std: 11, cxx: clang++-5.0, bt: Debug , vg: on}
- {std: 11, cxx: clang++-5.0, bt: Release, vg: on}
- {std: 11, cxx: clang++-4.0, bt: Debug , vg: on}
- {std: 11, cxx: clang++-4.0, bt: Release, vg: on}
- {std: 11, cxx: clang++-3.9, bt: Debug , vg: on}
- {std: 11, cxx: clang++-3.9, bt: Release, vg: on}
- {std: 11, cxx: clang++-16 , bt: Debug , vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-16 , bt: Release, vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-15 , bt: Debug , vg: on, img: ubuntu22.04} # install of clang15 fails on ubuntu18.04
- {std: 11, cxx: clang++-15 , bt: Release, vg: on, img: ubuntu22.04} # install of clang15 fails on ubuntu18.04
- {std: 11, cxx: clang++-14 , bt: Debug , vg: on, img: ubuntu22.04} # install of clang14 fails on ubuntu18.04
- {std: 11, cxx: clang++-14 , bt: Release, vg: on, img: ubuntu22.04} # install of clang14 fails on ubuntu18.04
- {std: 11, cxx: clang++-13 , bt: Debug , vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-13 , bt: Release, vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-12 , bt: Debug , vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-12 , bt: Release, vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-11 , bt: Debug , vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-11 , bt: Release, vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-10 , bt: Debug , vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-10 , bt: Release, vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-9 , bt: Debug , vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-9 , bt: Release, vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-8 , bt: Debug , vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-8 , bt: Release, vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-7 , bt: Debug , vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-7 , bt: Release, vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-6.0, bt: Debug , vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-6.0, bt: Release, vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-5.0, bt: Debug , vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-5.0, bt: Release, vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-4.0, bt: Debug , vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-4.0, bt: Release, vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-3.9, bt: Debug , vg: on, img: ubuntu18.04}
- {std: 11, cxx: clang++-3.9, bt: Release, vg: on, img: ubuntu18.04}
env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"}
steps:
- {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}}
Expand Down Expand Up @@ -165,8 +177,8 @@ jobs:
- {name: shared32-pack, run: source .github/setenv.sh && c4_package shared32}

#----------------------------------------------------------------------------
clang_sanitize:
name: clang_sanitize/c++${{matrix.std}}/${{matrix.bt}}/vg${{matrix.vg}}
clangsan:
name: clang/${{matrix.bt}}/c++${{matrix.std}}
continue-on-error: true
if: always() # https://stackoverflow.com/questions/62045967/github-actions-is-there-a-way-to-continue-on-error-while-still-getting-correct
runs-on: ubuntu-latest
Expand All @@ -175,23 +187,22 @@ jobs:
fail-fast: false
matrix:
include:
# these jobs take much longer, so run only one bitlink pair per job to profit from parallelism
- {std: 11, cxx: clang++-10 , bt: Debug , vg: ON, san: ALL, bitlinks: shared64 static64}
- {std: 11, cxx: clang++-10 , bt: Debug , vg: ON, san: ALL, bitlinks: shared32 static32}
- {std: 11, cxx: clang++-10 , bt: Release, vg: ON, san: ALL, bitlinks: shared64 static64}
- {std: 11, cxx: clang++-10 , bt: Release, vg: ON, san: ALL, bitlinks: shared32 static32}
- {std: 14, cxx: clang++-10 , bt: Debug , vg: ON, san: ALL, bitlinks: shared64 static64}
- {std: 14, cxx: clang++-10 , bt: Debug , vg: ON, san: ALL, bitlinks: shared32 static32}
- {std: 14, cxx: clang++-10 , bt: Release, vg: ON, san: ALL, bitlinks: shared64 static64}
- {std: 14, cxx: clang++-10 , bt: Release, vg: ON, san: ALL, bitlinks: shared32 static32}
- {std: 17, cxx: clang++-10 , bt: Debug , vg: ON, san: ALL, bitlinks: shared64 static64}
- {std: 17, cxx: clang++-10 , bt: Debug , vg: ON, san: ALL, bitlinks: shared32 static32}
- {std: 17, cxx: clang++-10 , bt: Release, vg: ON, san: ALL, bitlinks: shared64 static64}
- {std: 17, cxx: clang++-10 , bt: Release, vg: ON, san: ALL, bitlinks: shared32 static32}
- {std: 20, cxx: clang++-10 , bt: Debug , vg: ON, san: ALL, bitlinks: shared64 static64}
- {std: 20, cxx: clang++-10 , bt: Debug , vg: ON, san: ALL, bitlinks: shared32 static32}
- {std: 20, cxx: clang++-10 , bt: Release, vg: ON, san: ALL, bitlinks: shared64 static64}
- {std: 20, cxx: clang++-10 , bt: Release, vg: ON, san: ALL, bitlinks: shared32 static32}
- {std: 11, cxx: clang++-16 , bt: asan, bitlinks: static64}
- {std: 14, cxx: clang++-16 , bt: asan, bitlinks: static64}
- {std: 17, cxx: clang++-16 , bt: asan, bitlinks: static64}
- {std: 20, cxx: clang++-16 , bt: asan, bitlinks: static64}
- {std: 11, cxx: clang++-16 , bt: lsan, bitlinks: static64}
- {std: 14, cxx: clang++-16 , bt: lsan, bitlinks: static64}
- {std: 17, cxx: clang++-16 , bt: lsan, bitlinks: static64}
- {std: 20, cxx: clang++-16 , bt: lsan, bitlinks: static64}
- {std: 11, cxx: clang++-16 , bt: tsan, bitlinks: static64}
- {std: 14, cxx: clang++-16 , bt: tsan, bitlinks: static64}
- {std: 17, cxx: clang++-16 , bt: tsan, bitlinks: static64}
- {std: 20, cxx: clang++-16 , bt: tsan, bitlinks: static64}
- {std: 11, cxx: clang++-16 , bt: ubsan, bitlinks: static64}
- {std: 14, cxx: clang++-16 , bt: ubsan, bitlinks: static64}
- {std: 17, cxx: clang++-16 , bt: ubsan, bitlinks: static64}
- {std: 20, cxx: clang++-16 , bt: ubsan, bitlinks: static64}
env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"}
steps:
- {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}}
Expand Down
102 changes: 81 additions & 21 deletions .github/workflows/gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,33 +120,93 @@ jobs:
continue-on-error: true
if: always() # https://stackoverflow.com/questions/62045967/github-actions-is-there-a-way-to-continue-on-error-while-still-getting-correct
runs-on: ubuntu-latest
container: ghcr.io/biojppm/c4core/ubuntu18.04:latest # use the docker image
container: ghcr.io/biojppm/c4core/${{matrix.img}}:latest # use the docker image
strategy:
fail-fast: false
matrix:
include:
# VALGRIND
- {std: 11, cxx: g++-10, bt: Debug , vg: ON}
- {std: 11, cxx: g++-10, bt: Release, vg: ON}
- {std: 14, cxx: g++-10, bt: Debug , vg: ON}
- {std: 14, cxx: g++-10, bt: Release, vg: ON}
- {std: 17, cxx: g++-10, bt: Debug , vg: ON}
- {std: 17, cxx: g++-10, bt: Release, vg: ON}
- {std: 20, cxx: g++-10, bt: Debug , vg: ON}
- {std: 20, cxx: g++-10, bt: Release, vg: ON}
- {std: 11, cxx: g++-12, bt: Debug , vg: ON, img: ubuntu22.04}
- {std: 11, cxx: g++-12, bt: Release, vg: ON, img: ubuntu22.04}
- {std: 14, cxx: g++-12, bt: Debug , vg: ON, img: ubuntu22.04}
- {std: 14, cxx: g++-12, bt: Release, vg: ON, img: ubuntu22.04}
- {std: 17, cxx: g++-12, bt: Debug , vg: ON, img: ubuntu22.04}
- {std: 17, cxx: g++-12, bt: Release, vg: ON, img: ubuntu22.04}
- {std: 20, cxx: g++-12, bt: Debug , vg: ON, img: ubuntu22.04}
- {std: 20, cxx: g++-12, bt: Release, vg: ON, img: ubuntu22.04}
#
- {std: 11, cxx: g++-9, bt: Debug }
- {std: 11, cxx: g++-9, bt: Release}
- {std: 11, cxx: g++-8, bt: Debug }
- {std: 11, cxx: g++-8, bt: Release}
- {std: 11, cxx: g++-7, bt: Debug }
- {std: 11, cxx: g++-7, bt: Release}
- {std: 11, cxx: g++-6, bt: Debug }
- {std: 11, cxx: g++-6, bt: Release}
- {std: 11, cxx: g++-5, bt: Debug }
- {std: 11, cxx: g++-5, bt: Release}
- {std: 11, cxx: g++-4.8, bt: Debug}
- {std: 11, cxx: g++-4.8, bt: Release}
- {std: 11, cxx: g++-11 , bt: Debug , img: ubuntu18.04}
- {std: 11, cxx: g++-11 , bt: Release, img: ubuntu18.04}
- {std: 11, cxx: g++-10 , bt: Debug , img: ubuntu18.04}
- {std: 11, cxx: g++-10 , bt: Release, img: ubuntu18.04}
- {std: 11, cxx: g++-9 , bt: Debug , img: ubuntu18.04}
- {std: 11, cxx: g++-9 , bt: Release, img: ubuntu18.04}
- {std: 11, cxx: g++-8 , bt: Debug , img: ubuntu18.04}
- {std: 11, cxx: g++-8 , bt: Release, img: ubuntu18.04}
- {std: 11, cxx: g++-7 , bt: Debug , img: ubuntu18.04}
- {std: 11, cxx: g++-7 , bt: Release, img: ubuntu18.04}
- {std: 11, cxx: g++-6 , bt: Debug , img: ubuntu18.04}
- {std: 11, cxx: g++-6 , bt: Release, img: ubuntu18.04}
- {std: 11, cxx: g++-5 , bt: Debug , img: ubuntu18.04}
- {std: 11, cxx: g++-5 , bt: Release, img: ubuntu18.04}
- {std: 11, cxx: g++-4.9, bt: Debug , img: ubuntu18.04}
- {std: 11, cxx: g++-4.9, bt: Release, img: ubuntu18.04}
- {std: 11, cxx: g++-4.8, bt: Debug , img: ubuntu18.04}
- {std: 11, cxx: g++-4.8, bt: Release, img: ubuntu18.04}
env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"}
steps:
- {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}}
- run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169
- run: c4core-install ${{matrix.cxx}}
- {name: show info, run: source .github/setenv.sh && c4_show_info}
- name: shared64-configure---------------------------------------------------
run: source .github/setenv.sh && c4_cfg_test shared64
- {name: shared64-build, run: source .github/setenv.sh && c4_build_test shared64}
- {name: shared64-run, run: source .github/setenv.sh && c4_run_test shared64}
- {name: shared64-pack, run: source .github/setenv.sh && c4_package shared64}
- name: static64-configure---------------------------------------------------
run: source .github/setenv.sh && c4_cfg_test static64
- {name: static64-build, run: source .github/setenv.sh && c4_build_test static64}
- {name: static64-run, run: source .github/setenv.sh && c4_run_test static64}
- {name: static64-pack, run: source .github/setenv.sh && c4_package static64}
- name: static32-configure---------------------------------------------------
run: source .github/setenv.sh && c4_cfg_test static32
- {name: static32-build, run: source .github/setenv.sh && c4_build_test static32}
- {name: static32-run, run: source .github/setenv.sh && c4_run_test static32}
- {name: static32-pack, run: source .github/setenv.sh && c4_package static32}
- name: shared32-configure---------------------------------------------------
run: source .github/setenv.sh && c4_cfg_test shared32
- {name: shared32-build, run: source .github/setenv.sh && c4_build_test shared32}
- {name: shared32-run, run: source .github/setenv.sh && c4_run_test shared32}
- {name: shared32-pack, run: source .github/setenv.sh && c4_package shared32}

#----------------------------------------------------------------------------
gccsan:
name: gccsan/${{matrix.cxx}}/c++${{matrix.std}}/${{matrix.bt}}/vg${{matrix.vg}}
continue-on-error: true
if: always() # https://stackoverflow.com/questions/62045967/github-actions-is-there-a-way-to-continue-on-error-while-still-getting-correct
runs-on: ubuntu-latest
container: ghcr.io/biojppm/c4core/ubuntu22.04:latest # use the docker image
strategy:
fail-fast: false
matrix:
include:
- {std: 11, cxx: g++-12, bt: asan, bitlinks: static64}
- {std: 14, cxx: g++-12, bt: asan, bitlinks: static64}
- {std: 17, cxx: g++-12, bt: asan, bitlinks: static64}
- {std: 20, cxx: g++-12, bt: asan, bitlinks: static64}
- {std: 11, cxx: g++-12, bt: lsan, bitlinks: static64}
- {std: 14, cxx: g++-12, bt: lsan, bitlinks: static64}
- {std: 17, cxx: g++-12, bt: lsan, bitlinks: static64}
- {std: 20, cxx: g++-12, bt: lsan, bitlinks: static64}
- {std: 11, cxx: g++-12, bt: tsan, bitlinks: static64}
- {std: 14, cxx: g++-12, bt: tsan, bitlinks: static64}
- {std: 17, cxx: g++-12, bt: tsan, bitlinks: static64}
- {std: 20, cxx: g++-12, bt: tsan, bitlinks: static64}
- {std: 11, cxx: g++-12, bt: ubsan, bitlinks: static64}
- {std: 14, cxx: g++-12, bt: ubsan, bitlinks: static64}
- {std: 17, cxx: g++-12, bt: ubsan, bitlinks: static64}
- {std: 20, cxx: g++-12, bt: ubsan, bitlinks: static64}
env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"}
steps:
- {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}}
Expand Down
2 changes: 1 addition & 1 deletion cmake
Submodule cmake updated 1 files
+6 −6 c4Project.cmake
10 changes: 7 additions & 3 deletions src/c4/charconv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,10 @@ inline size_t from_chars_first(csubstr buf, bool * C4_RESTRICT v) noexcept
inline size_t to_chars(substr buf, char v) noexcept
{
if(buf.len > 0)
buf[0] = v;
{
C4_XASSERT(buf.str);
buf.str[0] = v;
}
return 1;
}

Expand All @@ -2284,15 +2287,16 @@ inline bool from_chars(csubstr buf, char * C4_RESTRICT v) noexcept
{
if(buf.len != 1)
return false;
*v = buf[0];
C4_XASSERT(buf.str);
*v = buf.str[0];
return true;
}

inline size_t from_chars_first(csubstr buf, char * C4_RESTRICT v) noexcept
{
if(buf.len < 1)
return csubstr::npos;
*v = buf[0];
*v = buf.str[0];
return 1;
}

Expand Down
8 changes: 4 additions & 4 deletions src/c4/substr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ struct C4CORE_EXPORT basic_substring
{
if(C4_LIKELY(*start_pos < len))
{
for(size_t i = *start_pos, e = len; i < e; i++)
for(size_t i = *start_pos; i < len; i++)
{
if(str[i] == sep)
{
Expand All @@ -1612,13 +1612,13 @@ struct C4CORE_EXPORT basic_substring
else
{
bool valid = len > 0 && (*start_pos == len);
if(valid && !empty() && str[len-1] == sep)
if(valid && str && str[len-1] == sep)
{
out->assign(str + len, (size_t)0); // the cast is needed to prevent overload ambiguity
out->assign(str + len, size_t(0)); // the cast is needed to prevent overload ambiguity
}
else
{
out->assign(str + len + 1, (size_t)0); // the cast is needed to prevent overload ambiguity
out->assign(str + len + 1, size_t(0)); // the cast is needed to prevent overload ambiguity
}
*start_pos = len + 1;
return valid;
Expand Down
2 changes: 1 addition & 1 deletion src/c4/type_name.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ C4_CONSTEXPR14 cspan<char> type_name()
// Note: subtract 7 at the end because the function terminates with ">(void)" in VS2015+
cspan<char>::size_type tstart = 26, tend = 7;

const char *s = p.str + tstart; // look at the start
const char *C4_RESTRICT s = p.str + tstart; // look at the start

// we're not using strcmp() or memcmp() to spare the #include

Expand Down
Loading

0 comments on commit 49435aa

Please sign in to comment.