Skip to content

Fix Rust agent build break on newer nightly by upgrading printf-compat#37

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-rust-compilation-errors
Open

Fix Rust agent build break on newer nightly by upgrading printf-compat#37
Copilot wants to merge 2 commits intomainfrom
copilot/fix-rust-compilation-errors

Conversation

Copy link

Copilot AI commented Mar 2, 2026

Rust agent compilation (python3 nimplant.py compile exe rust) was failing in Docker with printf-compat errors (VaArgSafe trait and VaList lifetime/API mismatches) on newer nightly toolchains. The failure path was in COFF loader printf handling used by risky-mode functionality.

  • Dependency update (root cause)

    • Bumped client-rs optional dependency:
      • printf-compat: 0.1.1 -> 0.3.1
    • Refreshed Cargo.lock to align transitive deps required by the newer crate.
  • API compatibility updates in COFF loader

    • Updated variadic forwarding in beacon_api.rs to match printf-compat 0.3.x API:
      • pass args directly to printf_compat::format(...)
      • removed old args.as_va_list() usage at both call sites.
  • Scope

    • Changes are limited to Rust agent dependency resolution and two call-site adjustments in Beacon-format/printf code paths.
// before
printf_compat::format(fmt, args.as_va_list(), printf_compat::output::fmt_write(&mut s));

// after
printf_compat::format(fmt, args, printf_compat::output::fmt_write(&mut s));
Original prompt

This section details on the original issue you should resolve

<issue_title>Rust Compliation Errors</issue_title>
<issue_description>- [ x] This issue is not about OPSEC or bypassing defensive products


OS and version: Provided Docker container
Using Docker: Yes


Issue Description
Attempting to compile the Rust agent using:
python3 nimplant.py compile exe rust

results in multiple errors regarding "the nightly-only, unstable trait VArgSafe is not implemented for u8 " with types i8 and u16 also throwing errors.

The source seems to be the printf-compat-0.1.1 parser package.

</issue_description>

<agent_instructions>Follow the README and use the provided docker container to try to reproduce the user's compilation issue. If you are able to reproduce it, implement a targeted fix, updating dependencies where needed (suspected dependency issue). If you cannot reproduce it, please provide a report on what you did and what the result was on your end, and give the user targeted steps to fix the issue or provide you with the necessary information to reproduce.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Summary by CodeRabbit

  • Chores
    • Updated the printf-compat dependency to version 0.3.1, bringing in updates to the formatting library that supports text processing capabilities throughout the application.

Co-authored-by: chvancooten <25614522+chvancooten@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Rust compilation errors in agent Fix Rust agent build break on newer nightly by upgrading printf-compat Mar 2, 2026
@chvancooten chvancooten marked this pull request as ready for review March 2, 2026 14:09
@chvancooten
Copy link
Owner

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Mar 2, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Mar 2, 2026

📝 Walkthrough

Walkthrough

Updated printf-compat dependency from 0.1.1 to 0.3.1 and modified beacon_api module to pass arguments directly to printf_compat::format instead of using as_va_list(), resolving nightly trait compilation errors.

Changes

Cohort / File(s) Summary
Dependency Update
client-rs/Cargo.toml
Bumped printf-compat from 0.1.1 to 0.3.1 (optional dependency).
API Call Updates
client-rs/src/app/coff_loader/beacon_api.rs
Refactored beacon_format_printf and beacon_printf functions to pass args directly instead of args.as_va_list() to align with printf-compat 0.3.1 API.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A printf adventure most fine,
where versions align and do shine,
From 0.1 to 0.3 we spring,
no more traits that unstable things bring,
Our Rust compiles swift—hooray!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing a Rust compilation issue by upgrading the printf-compat dependency.
Linked Issues check ✅ Passed The PR successfully addresses issue #36 by upgrading printf-compat from 0.1.1 to 0.3.1 and updating API calls to resolve VArgSafe/VaList compilation errors on newer nightly toolchains.
Out of Scope Changes check ✅ Passed All changes are directly related to resolving the printf-compat compilation issue: dependency version bump in Cargo.toml and two corresponding API call-site updates in beacon_api.rs.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch copilot/fix-rust-compilation-errors

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

Copy link

@coderabbitai coderabbitai bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In `@client-rs/src/app/coff_loader/beacon_api.rs`:
- Around line 460-464: The calls to printf_compat::format currently pass the raw
variadic VaListImpl (`args`) but the 0.3.x API expects core::ffi::VaList; update
both call sites that invoke printf_compat::format (the one using
printf_compat::output::fmt_write(&mut s) and the other similar call later) to
pass args.as_va_list() instead of args so the variadic arguments are converted
to the required core::ffi::VaList type.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af61429 and c5b27a0.

⛔ Files ignored due to path filters (1)
  • client-rs/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • client-rs/Cargo.toml
  • client-rs/src/app/coff_loader/beacon_api.rs

Comment on lines 460 to 464
let bytes_written = printf_compat::format(
fmt,
args.as_va_list(),
args,
printf_compat::output::fmt_write(&mut s),
);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

printf-compat 0.3 rust crate format function signature VaListMut

💡 Result:

In printf-compat 0.3.x, the formatter function takes core::ffi::VaList, not VaListMut:

pub unsafe fn format(
    format: *const c_char,
    args: core::ffi::VaList<'_>,
    handler: impl FnMut(Argument<'_>) -> c_int,
) -> c_int

[1]

If what you have is the Rust variadic “...” parameter (a VaListImpl), convert it to a VaList with as_va_list() and pass that to printf_compat::format:

#![feature(c_variadic)]

use core::ffi::{c_char, c_int, VaListImpl};
use printf_compat::{format, output};

unsafe extern "C" fn my_printf(fmt: *const c_char, mut ap: ...) -> c_int {
    // ap is VaListImpl; convert to VaList for printf-compat:
    let args = ap.as_va_list(); // -> VaList
    format(fmt, args, output::discard())
}

VaListImpl::as_va_list(&mut self) -> VaList<...> is the intended bridge here. [2]

Sources:
[1] printf_compat::format signature (docs.rs) (docs.rs)
[2] std::ffi::VaListImpl::as_va_list docs (doc.rust-lang.org)

Citations:


🏁 Script executed:

# Examine the beacon_api.rs file at the mentioned lines
# First, let's check the file exists and get its size
wc -l client-rs/src/app/coff_loader/beacon_api.rs

# Read the code around lines 460-464 (beacon_format_printf)
echo "=== Lines 452-477 (beacon_format_printf) ==="
sed -n '452,477p' client-rs/src/app/coff_loader/beacon_api.rs

# Read the code around lines 579 (beacon_printf)
echo "=== Lines 574-586 (beacon_printf) ==="
sed -n '574,586p' client-rs/src/app/coff_loader/beacon_api.rs

Repository: chvancooten/NimPlant

Length of output: 1116


Add .as_va_list() conversion to variadic arguments.

The printf_compat::format() function in version 0.3.x requires core::ffi::VaList, not the raw variadic VaListImpl. Both call sites (lines 462 and 579) must convert args before passing it:

let bytes_written = printf_compat::format(
    fmt,
    args.as_va_list(),
    printf_compat::output::fmt_write(&mut s),
);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@client-rs/src/app/coff_loader/beacon_api.rs` around lines 460 - 464, The
calls to printf_compat::format currently pass the raw variadic VaListImpl
(`args`) but the 0.3.x API expects core::ffi::VaList; update both call sites
that invoke printf_compat::format (the one using
printf_compat::output::fmt_write(&mut s) and the other similar call later) to
pass args.as_va_list() instead of args so the variadic arguments are converted
to the required core::ffi::VaList type.

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.

Rust Compliation Errors

2 participants