CodeSampleX

Exemplo

backtrace 0.3.76: backtrace::BacktraceFrame

Amostra verificada para cargo backtrace 0.3.76: backtrace::BacktraceFrame. O contrato rodou em rust 1 · linux alpine/x64 · docker e passou.

sha256:cac542f8d9c0e564c8ffc5b744bf196ee26ddbfaee1cf35d5a4c52e6012d8dfc

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux · alpine · musl x64 cargo

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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-09-20

Caso

HOW
Objetivo
verify backtrace::BacktraceFrame in pkg:cargo/backtrace@0.3.76
Pacotes
Símbolos
  • backtrace::BacktraceFrame
Criado
2026-09-20T16:50:36Z

Contrato

  1. Backtrace::new_unresolved captures BacktraceFrame entries where symbols are initially empty
  2. BacktraceFrame provides instruction pointer and symbol starting address
  3. BacktraceFrame::resolve resolves symbolic metadata including function names and addresses
  4. BacktraceFrame can be constructed from raw trace Frame via From trait
  5. BacktraceFrame implements Clone and can be collected into Backtrace via From<Vec<BacktraceFrame>>

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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::BacktraceFrame 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::BacktraceFrame

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:1e833c16384213c8b7999599e636c6e24e9dc5bff58fc09b501b9cba610b2cff","contract":["Backtrace::new_unresolved captures BacktraceFrame entries where symbols are initially empty","BacktraceFrame provides instruction pointer and symbol starting address","BacktraceFrame::resolve resolves symbolic metadata including function names and addresses","BacktraceFrame can be constructed from raw trace Frame via From trait","BacktraceFrame implements Clone and can be collected into Backtrace via From\u003cVec\u003cBacktraceFrame\u003e\u003e"],"goal":"verify backtrace::BacktraceFrame in pkg:cargo/backtrace@0.3.76","kind":"HOW","packages":["pkg:cargo/backtrace@0.3.76"],"schemaVersion":1,"symbols":["backtrace::BacktraceFrame"]},"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::BacktraceFrame"],"verifierAdapter":"cargo@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify backtrace::BacktraceFrame in pkg:cargo/backtrace@0.3.76",
  "kind": "HOW",
  "packages": [
    "pkg:cargo/backtrace@0.3.76"
  ],
  "symbols": [
    "backtrace::BacktraceFrame"
  ]
}
src/lib.rs
//! Clean-room verification sample for backtrace.

pub use backtrace::*;
test/contract.rs
use backtrace::{trace, Backtrace, BacktraceFrame};

#[inline(never)]
fn sample_target_function() -> Backtrace {
    Backtrace::new_unresolved()
}

fn main() {
    // 1. Backtrace::new_unresolved captures BacktraceFrame entries where symbols are initially empty
    let bt = sample_target_function();
    let frames: &[BacktraceFrame] = bt.frames();
    assert!(!frames.is_empty(), "frames should not be empty");
    let first_frame = &frames[0];
    assert!(first_frame.symbols().is_empty(), "unresolved frame has empty symbols");

    // 2. BacktraceFrame provides instruction pointer and symbol starting address
    let ip = first_frame.ip();
    assert!(!ip.is_null(), "ip should not be null");
    let sym_addr = first_frame.symbol_address();
    assert!(!sym_addr.is_null(), "symbol_address should not be null");
    let _module_base = first_frame.module_base_address();

    // 3. BacktraceFrame::resolve resolves symbolic metadata including function names and addresses
    let mut resolved_frame = first_frame.clone();
    resolved_frame.resolve();
    let symbols = resolved_frame.symbols();
    assert!(!symbols.is_empty(), "resolved frame should have at least one symbol");
    let sym = &symbols[0];
    assert!(sym.name().is_some(), "symbol should have a name");
    let name_str = sym.name().unwrap().to_string();
    assert!(!name_str.is_empty(), "symbol name string should not be empty");

    // 4. BacktraceFrame can be constructed from raw trace Frame via From trait
    let mut captured_from_raw = None;
    trace(|raw_frame| {
        let frame = BacktraceFrame::from(raw_frame.clone());
        assert!(!frame.ip().is_null());
        captured_from_raw = Some(frame);
        false // stop after first frame
    });
    assert!(captured_from_raw.is_some(), "should capture frame from raw");

    // 5. BacktraceFrame implements Clone and can be collected into Backtrace via From<Vec<BacktraceFrame>>
    let cloned_frame = resolved_frame.clone();
    assert_eq!(cloned_frame.ip(), resolved_frame.ip());
    assert_eq!(cloned_frame.symbol_address(), resolved_frame.symbol_address());
    let frames_vec = vec![cloned_frame];
    let reconstituted_bt = Backtrace::from(frames_vec);
    assert_eq!(reconstituted_bt.frames().len(), 1);
    assert_eq!(reconstituted_bt.frames()[0].ip(), resolved_frame.ip());

    println!("All BacktraceFrame contract assertions passed.");
}

Seeder de origem

anônimo