Skip to content

Use ASAN when running unit tests in CI#56

Merged
erthalion merged 5 commits into
mainfrom
jv-use-asan
Jul 22, 2026
Merged

Use ASAN when running unit tests in CI#56
erthalion merged 5 commits into
mainfrom
jv-use-asan

Conversation

@JoukoVirtanen

@JoukoVirtanen JoukoVirtanen commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Adds CI unit test jobs with and without ASAN.

The ASAN tests found a failure https://github.com/stackrox/berserker/actions/runs/24287041420/job/70918030561?pr=56 when the target branch was #55

@JoukoVirtanen
JoukoVirtanen changed the base branch from main to feature/new-script-worker March 26, 2026 02:57
@JoukoVirtanen
JoukoVirtanen marked this pull request as draft March 26, 2026 05:29
Comment thread .github/workflows/main.yml Outdated
Comment thread .github/workflows/main.yml Outdated
@JoukoVirtanen
JoukoVirtanen marked this pull request as ready for review March 26, 2026 21:22
@JoukoVirtanen
JoukoVirtanen requested a review from erthalion March 26, 2026 21:22
Comment thread .github/workflows/main.yml Outdated
source "${HOME}"/.cargo/env &&
rustup component add rust-src --toolchain nightly &&
TARGET=$(rustc --version --verbose | grep host | cut -d" " -f2) &&
RUSTFLAGS="-Z sanitizer=address" cargo +nightly test -Z build-std --target "$TARGET"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are invoked from the image itself nowadays:
https://github.com/stackrox/berserker/blob/main/Dockerfile.build#L32

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now invoke the ASAN unit tests from the image itself.

@erthalion
erthalion force-pushed the feature/new-script-worker branch from 881dc23 to d030a12 Compare March 31, 2026 16:35
@erthalion
erthalion force-pushed the feature/new-script-worker branch from d030a12 to c135bad Compare April 8, 2026 15:13
@JoukoVirtanen
JoukoVirtanen requested a review from erthalion April 11, 2026 17:21
@JoukoVirtanen
JoukoVirtanen changed the base branch from feature/new-script-worker to main April 12, 2026 17:47
@erthalion
erthalion force-pushed the jv-use-asan branch 2 times, most recently from ebc47a6 to bcef02e Compare May 8, 2026 12:27
@erthalion erthalion mentioned this pull request Jul 2, 2026
JoukoVirtanen and others added 2 commits July 7, 2026 17:02
Co-authored-by: Dmitrii Dolgov <9erthalion6@gmail.com>
To prevent memory leaks from allocations in helper functions, remember
references to allocated objects. For now we assume only CString is
reference.
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 01af4ec7-5c39-4121-9b5b-05139e58327a

📥 Commits

Reviewing files that changed from the base of the PR and between e1fd93e and 8804dab.

📒 Files selected for processing (1)
  • Cargo.toml
💤 Files with no reviewable changes (1)
  • Cargo.toml

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added configurable stable and nightly Rust build and test workflows.
    • Improved runtime cleanup for dynamically allocated script resources.
  • Bug Fixes

    • Prevented dynamically allocated script data from remaining unreleased after execution.
  • Documentation

    • Clarified inline documentation and configuration comments.
  • Chores

    • Default Cargo features are now explicitly empty.

Walkthrough

Adds configurable stable and nightly container testing with nightly address-sanitizer execution. It also tracks allocated JIT C-string pointers, releases them through a generated cleanup call, and reformats comments and documentation.

Changes

Nightly toolchain and script cleanup

Layer / File(s) Summary
Nightly toolchain and test flow
Cargo.toml, Containerfile, Makefile, Containerfile.test
Configures toolchain selection, nightly sanitizer tests, and stable/nightly container builds.
JIT runtime pointer tracking and dispatch
src/worker/script.rs
Tracks allocated path pointers, adds cleanup, renames the file-opening runtime symbol, and switches dispatch to C strings.
JIT instruction wiring and final cleanup
src/worker/script.rs
Passes C-string instruction names and emits a mapped final cleanup call.
Documentation and comment formatting
src/lib.rs, src/main.rs, src/worker/syscalls/ioctl.rs, src/worker/script.rs
Reformats documentation and comments without changing behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: erthalion

Sequence Diagram(s)

sequenceDiagram
  participant Makefile
  participant Containerfile
  participant Rustup
  participant Cargo
  participant ScriptWorker
  participant Runtime

  Makefile->>Containerfile: build nightly image
  Containerfile->>Rustup: install nightly toolchain and rust-src
  Containerfile->>Cargo: run sanitizer-enabled tests
  ScriptWorker->>Runtime: dispatch C-string instruction
  Runtime-->>ScriptWorker: return runtime result
  ScriptWorker->>Runtime: invoke final cleanup
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: running unit tests in CI with ASAN enabled.
Description check ✅ Passed The description is directly related to the changeset and accurately mentions CI unit tests with and without ASAN.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jv-use-asan

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Containerfile`:
- Line 1: Fix the Dockerfile lint issues by updating the stage alias in the
top-level FROM instruction to use matching uppercase AS, and change the
ENTRYPOINT in the Containerfile to JSON/exec form instead of shell form. Use the
FROM and ENTRYPOINT instructions in this file as the targets for the cleanup.
- Around line 45-50: The nightly ASAN test branch in the Containerfile is
missing the crate’s `nightly` Cargo feature, so the `sanitize` feature gate in
`src/lib.rs` never turns on. Update the `cargo +nightly test` invocation in this
RUN block to include the crate’s `nightly` feature alongside the existing `-Z
build-std` and `RUSTFLAGS="-Z sanitizer=address"` settings, so the ASAN path
actually exercises the intended nightly-only code.

In `@Makefile`:
- Around line 9-10: The Makefile’s two docker build steps currently reuse the
same berserker tag, so the nightly build overwrites the stable image. Update the
second docker build invocation to use a distinct tag for the nightly variant
while keeping the first build as the default berserker image, so later steps
consume the intended stable image; make this change in the build commands near
the two docker build lines.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: af1e2ced-f111-4070-bda9-21101f6c0352

📥 Commits

Reviewing files that changed from the base of the PR and between c4c211b and 2fab6d0.

📒 Files selected for processing (7)
  • Cargo.toml
  • Containerfile
  • Makefile
  • src/lib.rs
  • src/main.rs
  • src/worker/script.rs
  • src/worker/syscalls/ioctl.rs

Comment thread Containerfile Outdated
@@ -1,10 +1,8 @@
FROM registry.fedoraproject.org/fedora:43 as builder

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Minor Dockerfile lint fixes flagged by pipeline.

as should match FROM casing (AS) on line 1, and ENTRYPOINT should use JSON/exec form on line 62.

🧹 Proposed fix
-FROM registry.fedoraproject.org/fedora:43 as builder
+FROM registry.fedoraproject.org/fedora:43 AS builder
-ENTRYPOINT berserker
+ENTRYPOINT ["berserker"]

Also applies to: 62-62

🧰 Tools
🪛 GitHub Actions: Main berserker CI / 0_build-and-push.txt

[warning] 1-1: Dockerfile lint warning: FromAsCasing - 'as' and 'FROM' keywords' casing do not match.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Containerfile` at line 1, Fix the Dockerfile lint issues by updating the
stage alias in the top-level FROM instruction to use matching uppercase AS, and
change the ENTRYPOINT in the Containerfile to JSON/exec form instead of shell
form. Use the FROM and ENTRYPOINT instructions in this file as the targets for
the cleanup.

Source: Pipeline failures

Comment thread Containerfile
Comment thread Makefile Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Containerfile.test`:
- Line 1: Update the Containerfile.test base image and the Makefile targets that
build and run tests so the base image is explicitly selectable, with distinct
stable and nightly test images exercising their corresponding toolchains. Ensure
the default test flow runs the stable image while retaining an explicit nightly
test path, and avoid leaving either built tool image unused.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 4442deaf-4b9b-4bd7-9a9a-363557287891

📥 Commits

Reviewing files that changed from the base of the PR and between 1b0246c and a481d28.

📒 Files selected for processing (5)
  • Containerfile
  • Containerfile.test
  • Makefile
  • src/lib.rs
  • src/worker/script.rs
💤 Files with no reviewable changes (1)
  • src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • Makefile
  • Containerfile
  • src/worker/script.rs

Comment thread Containerfile.test Outdated

@Molter73 Molter73 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A single comment on the nightly feature probably being able to be removed, otherwise LGTM!

Comment thread Cargo.toml Outdated

[features]
default = []
nightly = []

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this feature?

@erthalion
erthalion merged commit ec43ada into main Jul 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants