CodeSampleX

샘플

backtrace 0.3.76: backtrace::trace

검증된 샘플 — cargo backtrace 0.3.76: backtrace::trace. rust 1 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: backtrace::trace yields stack frames to the…

sha256:4938492fa86d9b2964736ac78e8884c0ee29aa94eff58343f67c5dd990d7753e

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 linux · alpine · musl x64 cargo

검증 실행 환경

환경 컨트랙트 단계 실행일
rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b…
2026-10-09

케이스

HOW
목표
verify backtrace::trace in pkg:cargo/backtrace@0.3.76
패키지
심벌
  • backtrace::trace
생성일
2026-10-09T08:17:02Z

컨트랙트

  1. backtrace::trace yields stack frames to the provided closure
  2. backtrace::trace yields frames with valid non-null instruction pointer
  3. backtrace::trace terminates iteration early when closure returns false
  4. backtrace::trace captures deeper stack during nested function calls

파일

  • Cargo.lock
  • Cargo.toml
  • PROMPT.md
  • csx.json
  • spec.json
  • src/lib.rs
  • test/contract.rs

소스 아티팩트 내려받기 (tar.gz)

소스

Cargo.lock
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4

[[package]]
name = "addr2line"
version = "0.25.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b"
dependencies = [
 "gimli",
]

[[package]]
name = "adler2"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"

[[package]]
name = "backtrace"
version = "0.3.76"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6"
dependencies = [
 "addr2line",
 "cfg-if",
 "libc",
 "miniz_oxide",
 "object",
 "rustc-demangle",
 "windows-link",
]

[[package]]
name = "cfg-if"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"

[[package]]
name = "gimli"
version = "0.32.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"

[[package]]
name = "libc"
version = "0.2.189"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"

[[package]]
name = "memchr"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"

[[package]]
name = "miniz_oxide"
version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
dependencies = [
 "adler2",
]

[[package]]
name = "object"
version = "0.37.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe"
dependencies = [
 "memchr",
]

[[package]]
name = "rustc-demangle"
version = "0.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b74b56ffa8bb2830709a538c2cbcae9aa062db0d2a42563bfb09bdaae44020eb"

[[package]]
name = "sample-backtrace"
version = "1.0.0"
dependencies = [
 "backtrace",
]

[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
Cargo.toml
[package]
name = "sample-backtrace"
version = "1.0.0"
edition = "2021"
publish = false

[dependencies]
backtrace = "=0.3.76"

[[bin]]
name = "contract"
path = "test/contract.rs"
PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify backtrace::trace in pkg:cargo/backtrace@0.3.76
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:cargo/backtrace@0.3.76
Demonstrate these symbols/APIs:
  - backtrace::trace

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:04f3a9f5c6db4c12db902c67cf54b4c166aaacbc8324bc11bcf28d4aaa9b2630","contract":["backtrace::trace yields stack frames to the provided closure","backtrace::trace yields frames with valid non-null instruction pointer","backtrace::trace terminates iteration early when closure returns false","backtrace::trace captures deeper stack during nested function calls"],"goal":"verify backtrace::trace in pkg:cargo/backtrace@0.3.76","kind":"HOW","packages":["pkg:cargo/backtrace@0.3.76"],"schemaVersion":1,"symbols":["backtrace::trace"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"cargo","libc":"musl","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/backtrace@0.3.76"],"schemaVersion":1,"subject":"pkg:cargo/backtrace@0.3.76","symbols":["backtrace::trace"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify backtrace::trace in pkg:cargo/backtrace@0.3.76",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/backtrace@0.3.76"
  ],
  "symbols": [
    "backtrace::trace"
  ]
}
src/lib.rs
//! Clean-room verification sample for backtrace.

pub use backtrace::*;
test/contract.rs
use backtrace::trace;

fn nested_call(target_depth: usize, current_depth: usize, ips: &mut Vec<*mut core::ffi::c_void>) {
    if current_depth < target_depth {
        nested_call(target_depth, current_depth + 1, ips);
    } else {
        trace(|frame| {
            ips.push(frame.ip());
            true
        });
    }
}

fn main() {
    // 1. backtrace::trace yields stack frames to the provided closure
    let mut frames = Vec::new();
    trace(|frame| {
        frames.push(frame.ip());
        true
    });
    assert!(!frames.is_empty(), "Expected at least one frame from trace");

    // 2. backtrace::trace yields frames with valid non-null instruction pointer
    assert!(
        frames.iter().any(|&ip| !ip.is_null()),
        "At least one stack frame should have a non-null instruction pointer"
    );

    // 3. backtrace::trace terminates iteration early when closure returns false
    let mut early_stop_count = 0;
    trace(|_frame| {
        early_stop_count += 1;
        false
    });
    assert_eq!(
        early_stop_count, 1,
        "Trace should have stopped after exactly one frame when closure returns false"
    );

    // 4. backtrace::trace captures deeper stack during nested function calls
    let mut nested_ips = Vec::new();
    nested_call(5, 0, &mut nested_ips);
    assert!(
        nested_ips.len() >= 5,
        "Nested call stack should capture multiple frames (got {})",
        nested_ips.len()
    );

    println!("All backtrace::trace contract assertions passed successfully.");
}

오리진 시더

익명