Skip to content

Commit e5a8856

Browse files
committed
merge main: fuzz harness, sanitizer ci, license
2 parents a885ffc + 78ae3bb commit e5a8856

34 files changed

Lines changed: 241 additions & 0 deletions

‎.github/workflows/ci.yml‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,52 @@ jobs:
2020
run: cmake --build build --parallel
2121
- name: Test
2222
run: ctest --test-dir build --output-on-failure
23+
24+
sanitizers:
25+
runs-on: ubuntu-latest
26+
env:
27+
CC: clang
28+
CXX: clang++
29+
steps:
30+
- uses: actions/checkout@v4
31+
- name: Configure
32+
run: >-
33+
cmake -S . -B build-sanitizers
34+
-DCMAKE_BUILD_TYPE=Debug
35+
-DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer"
36+
- name: Build
37+
run: cmake --build build-sanitizers --parallel 2
38+
- name: Test
39+
run: ctest --test-dir build-sanitizers --output-on-failure
40+
41+
fuzz:
42+
runs-on: ubuntu-latest
43+
env:
44+
CC: clang
45+
CXX: clang++
46+
steps:
47+
- uses: actions/checkout@v4
48+
- name: Configure
49+
run: cmake -S . -B build-fuzz -DCMAKE_BUILD_TYPE=Debug -DSQL_ENGINE_BUILD_FUZZER=ON
50+
- name: Build
51+
run: cmake --build build-fuzz --target sql_parser_planner_fuzz --parallel 2
52+
- name: Replay corpus (regression gate)
53+
run: ./build-fuzz/sql_parser_planner_fuzz -timeout=10 fuzz/corpus/*
54+
- name: Short discovery session (non-blocking)
55+
continue-on-error: true
56+
run: >-
57+
./build-fuzz/sql_parser_planner_fuzz fuzz/corpus
58+
-max_total_time=90
59+
-timeout=10
60+
-rss_limit_mb=2048
61+
-print_final_stats=1
62+
- name: Upload discovery artifacts
63+
if: always()
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: fuzz-findings
67+
path: |
68+
crash-*
69+
timeout-*
70+
oom-*
71+
if-no-files-found: ignore

‎CMakeLists.txt‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set(CMAKE_CXX_STANDARD 20)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
77

8+
option(SQL_ENGINE_BUILD_FUZZER "Build the parser and planner fuzz target" OFF)
9+
810
add_library(sql_engine
911
src/sql/parser.cpp
1012
src/sql/binder.cpp
@@ -20,6 +22,21 @@ add_library(sql_engine
2022
target_include_directories(sql_engine PUBLIC include)
2123
target_compile_options(sql_engine PRIVATE -Wall -Wextra -Wpedantic)
2224

25+
if(SQL_ENGINE_BUILD_FUZZER)
26+
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
27+
message(FATAL_ERROR "SQL_ENGINE_BUILD_FUZZER requires Clang")
28+
endif()
29+
target_compile_options(sql_engine PRIVATE
30+
-fsanitize=fuzzer-no-link,address,undefined
31+
-fno-sanitize-recover=all
32+
-fno-omit-frame-pointer
33+
)
34+
target_link_options(sql_engine INTERFACE
35+
-fsanitize=address,undefined
36+
-fno-sanitize-recover=all
37+
)
38+
endif()
39+
2340
add_executable(sql_smoke tests/smoke.cpp)
2441
target_link_libraries(sql_smoke PRIVATE sql_engine)
2542

@@ -50,6 +67,20 @@ target_link_libraries(sql_bench PRIVATE sql_engine)
5067
add_executable(yard_export benchmarks/yard_export.cpp)
5168
target_link_libraries(yard_export PRIVATE sql_engine)
5269

70+
if(SQL_ENGINE_BUILD_FUZZER)
71+
add_executable(sql_parser_planner_fuzz fuzz/parser_planner_fuzz.cpp)
72+
target_link_libraries(sql_parser_planner_fuzz PRIVATE sql_engine)
73+
target_compile_options(sql_parser_planner_fuzz PRIVATE
74+
-fsanitize=fuzzer,address,undefined
75+
-fno-sanitize-recover=all
76+
-fno-omit-frame-pointer
77+
)
78+
target_link_options(sql_parser_planner_fuzz PRIVATE
79+
-fsanitize=fuzzer,address,undefined
80+
-fno-sanitize-recover=all
81+
)
82+
endif()
83+
5384
include(CTest)
5485
add_test(NAME sql_smoke COMMAND sql_smoke)
5586
add_test(NAME sql_golden COMMAND sql_golden)

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Affan Yasir
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ C++20, CMake, Arrow-like in-memory column batches, SIMD-friendly operator interf
1616
cmake -S . -B build && cmake --build build && ctest --test-dir build --output-on-failure
1717
```
1818

19+
Linux CI runs the full test suite with address and undefined-behavior sanitizers.
20+
Continuous parser and planner fuzzing replays known queries before a timed fuzzing run.
21+
1922
`yard_export` writes `docs/yard/yard-routes.json`: every memo alternative for four workings, priced by the cost model and timed through vectorized execution. See the "Yard Routes" section of `docs/benchmarks.md`.
2023

2124
## Phase map

‎fuzz/corpus/aggregate_having.sql‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT a, SUM(b) AS total FROM t GROUP BY a HAVING SUM(b) >= 20 ORDER BY total DESC

‎fuzz/corpus/anti_join.sql‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT a FROM t WHERE a NOT IN (SELECT a FROM t1)

‎fuzz/corpus/basic.sql‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT a FROM t WHERE a = 2

‎fuzz/corpus/boolean_tree.sql‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT a FROM t WHERE a = 1 AND (b = 20 OR a = 3)

‎fuzz/corpus/correlated_exists.sql‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT a FROM t WHERE EXISTS (SELECT t1.b FROM t1 WHERE t1.a = t.a)

‎fuzz/corpus/correlated_not_in.sql‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT b FROM t WHERE b NOT IN (SELECT t1.b FROM t1 WHERE t1.a = t.a)

0 commit comments

Comments
 (0)