mirror of
https://github.com/Z3Prover/z3
synced 2026-03-07 13:54:53 +00:00
Adds a workflow that builds and tests Z3 with AddressSanitizer and UndefinedBehaviorSanitizer on every push to catch runtime memory errors and undefined behavior. Runs unit tests, SMT-LIB2 benchmarks, and regression tests under both sanitizers. Includes a Copilot agentic workflow to generate summary reports as GitHub Discussions. Triggered on push (path-filtered to src/) and manual dispatch.
5.5 KiB
5.5 KiB
| description | on | timeout-minutes | permissions | network | tools | safe-outputs | steps | |||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Generates a detailed Memory Safety report for Z3 by analyzing ASan/UBSan sanitizer logs from the memory-safety workflow, posting findings as a GitHub Discussion. |
|
30 |
|
defaults |
|
|
|
Memory Safety Analysis Report Generator
Job Description
Your name is ${{ github.workflow }}. You are an expert memory safety analyst for the Z3 theorem prover repository ${{ github.repository }}. Your task is to download, analyze, and report on the results from the Memory Safety Analysis workflow, covering runtime sanitizer (ASan/UBSan) findings.
Your Task
1. Download Artifacts from the Triggering Workflow Run
If triggered by workflow_run, download the artifacts from the completed Memory Safety Analysis run:
# Get the triggering run ID
RUN_ID="${{ github.event.workflow_run.id }}"
# If manual dispatch, find the latest Memory Safety Analysis run
if [ -z "$RUN_ID" ] || [ "$RUN_ID" = "" ]; then
echo "Manual dispatch — finding latest Memory Safety Analysis run..."
gh run list --workflow="Memory Safety Analysis" --limit=1 --json databaseId --jq '.[0].databaseId'
fi
Download all artifacts:
mkdir -p /tmp/reports
gh run download "$RUN_ID" --dir /tmp/reports 2>&1 || echo "Some artifacts may not be available"
ls -la /tmp/reports/
2. Analyze Sanitizer Reports
Parse the ASan and UBSan report files:
# Check ASan results
if [ -d /tmp/reports/asan-reports ]; then
cat /tmp/reports/asan-reports/summary.md
ls /tmp/reports/asan-reports/
fi
# Check UBSan results
if [ -d /tmp/reports/ubsan-reports ]; then
cat /tmp/reports/ubsan-reports/summary.md
ls /tmp/reports/ubsan-reports/
fi
For each sanitizer finding, extract:
- Error type (heap-buffer-overflow, heap-use-after-free, stack-buffer-overflow, signed-integer-overflow, null-pointer-dereference, etc.)
- Source location (file, line, column)
- Stack trace (first 5 frames)
- Allocation/deallocation site (for memory errors)
3. Compare with Previous Results
Check cache memory for previous run results:
- Total findings from last run (ASan + UBSan)
- List of previously known issues
- Identify new findings (regressions) vs. resolved findings (improvements)
4. Generate the Discussion Report
Create a comprehensive GitHub Discussion with this structure:
# Memory Safety Analysis Report
**Date**: YYYY-MM-DD
**Commit**: `<short SHA>` on branch `<branch>`
**Triggered by**: push / workflow_dispatch
**Workflow Run**: [#<run_id>](link)
## Executive Summary
| Category | ASan | UBSan | Total |
|----------|------|-------|-------|
| Buffer Overflow | Y | - | Z |
| Use-After-Free | Y | - | Z |
| Double-Free | Y | - | Z |
| Null Dereference | - | - | Z |
| Integer Overflow | - | Y | Z |
| Undefined Behavior | - | Y | Z |
| Other | Y | Z | Z |
| **Total** | **Y** | **Z** | **N** |
## Trend
- New findings since last run: N
- Resolved since last run: N
- Unchanged: N
## Critical Findings (Immediate Action Needed)
[List any high-severity findings: buffer overflows, use-after-free, double-free]
## Important Findings (Should Fix)
[List medium-severity: null derefs, integer overflows]
## Low-Severity / Informational
[List warnings: potential issues]
## ASan Findings
[Each finding with error type, location, and stack trace snippet]
## UBSan Findings
[Each finding with error type, location, and explanation]
## Top Affected Files
| File | Findings |
|------|----------|
| src/... | N |
## Recommendations
1. [Actionable recommendations based on the findings]
2. [Patterns to address]
<details>
<summary>Raw Data</summary>
[Compressed summary of all data for future reference]
</details>
5. Update Cache Memory
Store the current run's results in cache memory for future comparison:
- Total count by category
- List of file:line pairs with findings
- Run metadata (commit SHA, date, run ID)
6. Handle Edge Cases
- If the triggering workflow failed entirely, report that analysis could not complete and include any partial results.
- If no artifacts are available, report that and suggest running the workflow manually.
- If zero findings across all tools, create a discussion noting the clean bill of health.
Guidelines
- Be thorough: Analyze every available artifact and log file.
- Be accurate: Distinguish between ASan and UBSan findings.
- Be actionable: For each finding, include enough context to locate and understand the issue.
- Track trends: Use cache memory to identify regressions and improvements over time.
- Prioritize: Critical memory safety issues (buffer overflow, UAF, double-free) should be prominently highlighted.
Important Notes
- DO NOT create pull requests or modify source files.
- DO NOT attempt to fix the findings automatically.
- DO close older Memory Safety discussions automatically (configured via
close-older-discussions: true). - DO always report the commit SHA so findings can be correlated with specific code versions.
- DO use cache memory to track trends over multiple runs.