Skip to content

Please publish v2.0.1 crate: SourceRange::tokenize() crashes in debug builds on Rust >= 1.78 — PR #58 has been merged for ~22 months #67

@sethml

Description

@sethml

I'm filing this to request a new crates.io release that includes the fix from PR #58.

The bug

SourceRange::tokenize() passes the raw pointer returned by clang_tokenize directly to slice::from_raw_parts without a null check. clang_tokenize can return null (e.g. for macro-expanded expressions or compiler builtins), which is undefined behavior. Starting with Rust 1.78, debug builds include precondition checks that catch this and abort:

unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null

This means any user of clang v2.0.0 on current stable Rust will crash in debug builds when tokenizing certain source ranges.

The fix

@madsmtm identified and fixed this in PR #58, which was merged on April 27, 2024. The fix is a simple null check — a one-liner change. It has been sitting merged and unreleased for nearly two years.

Request

Could you please publish v2.0.1 to crates.io with this fix included? This is a soundness/crash bug that affects all downstream users on Rust 1.78+.

If you no longer have time to maintain the crate, would you be willing to either:

  1. Grant publish access on crates.io to @madsmtm or another active contributor, or
  2. Transfer the crate to a community-maintained account?
    In the meantime, downstream crates are forced to use release-mode workarounds or complex git-dep pins (which have their own issues — later commits in the repo fail to compile with current Rust due to a separate unsafe fn coercion breakage).

Thanks for your work on this crate!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions