Skip to content

mkcgo: restore 1-arg slice attribute support#13

Merged
gdams merged 1 commit into
mainfrom
dev/gadams/fix-slice-parser
May 26, 2026
Merged

mkcgo: restore 1-arg slice attribute support#13
gdams merged 1 commit into
mainfrom
dev/gadams/fix-slice-parser

Conversation

@gdams
Copy link
Copy Markdown
Member

@gdams gdams commented May 26, 2026

The slice attribute handler was changed to require exactly 2 arguments in 920ecfb, but the Attrs.String() serializer still handles Len=="" correctly. This broke downstream consumers (go-crypto-darwin) that use slice(ptr) for fixed-size buffers with no explicit length parameter (e.g. IV, tag, key buffers with known sizes).

Restore support for 1 or 2 arguments to match the serializer behavior.

Fixes parsing errors like:

error parsing attribute slice: requires 2 arguments

for declarations such as:

CCCryptorStatus CCCryptorCreate(..., const void *iv, ...) __attribute__((slice(iv)));

The slice attribute handler was changed to require exactly 2 arguments
in 920ecfb, but the Attrs.String() serializer still handles Len==""
correctly. This broke downstream consumers (go-crypto-darwin) that use
slice(ptr) for fixed-size buffers with no explicit length parameter
(e.g. IV, tag, key buffers with known sizes).

Restore support for 1 or 2 arguments to match the serializer behavior.
Copilot AI review requested due to automatic review settings May 26, 2026 09:31
@gdams gdams requested a review from a team as a code owner May 26, 2026 09:31
@gdams gdams enabled auto-merge May 26, 2026 09:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR restores mkcgo’s slice attribute parsing to accept either 1 or 2 arguments, aligning the parser with the existing Attrs.String() serializer behavior and unblocking downstream headers that use slice(ptr) for fixed-size buffers.

Changes:

  • Update the slice attribute handler to accept 1 or 2 arguments (instead of requiring exactly 2).
  • Update parse-error test expectations to match the new error message for invalid slice arity.
Show a summary per file
File Description
internal/mkcgo/mkcgo.go Adjusts slice attribute arity validation and parsing to support slice(ptr) and slice(ptr,len).
internal/mkcgo/mkcgo_test.go Updates expected error messages for invalid slice attribute argument counts.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment thread internal/mkcgo/mkcgo.go
Comment thread internal/mkcgo/mkcgo.go
@gdams gdams merged commit f3ee9e4 into main May 26, 2026
113 of 115 checks passed
@gdams gdams deleted the dev/gadams/fix-slice-parser branch May 26, 2026 09:46
@github-actions
Copy link
Copy Markdown

Benchmark Results

⚠️ Issues detected — expand failed jobs below for details

ubuntu-22.04-go1.25-cgo1-ossl3.0.13 · results
ubuntu-22.04-go1.25-cgo1-ossl3.1.5 · results
ubuntu-22.04-go1.25-cgo1-ossl3.2.1 · results
ubuntu-22.04-go1.25-cgo1-ossl3.3.1 · results
ubuntu-22.04-go1.25-cgo1-ossl3.4.0 · results
ubuntu-22.04-go1.25-cgo1-ossl3.5.0 · results
ubuntu-22.04-go1.26-cgo1-ossl3.0.13 · results
ubuntu-22.04-go1.26-cgo1-ossl3.1.5 · results
ubuntu-22.04-go1.26-cgo1-ossl3.2.1 · results
ubuntu-22.04-go1.26-cgo1-ossl3.3.1 · results
ubuntu-22.04-go1.26-cgo1-ossl3.4.0 · results
ubuntu-22.04-go1.26-cgo1-ossl3.5.0 · results
ubuntu-24.04-arm-go1.25-cgo1-ossl3.0.13 · results
ubuntu-24.04-arm-go1.25-cgo1-ossl3.1.5 · results
ubuntu-24.04-arm-go1.25-cgo1-ossl3.2.1 · results
ubuntu-24.04-arm-go1.25-cgo1-ossl3.3.1 · results
ubuntu-24.04-arm-go1.25-cgo1-ossl3.4.0 · results

ubuntu-24.04-arm-go1.25-cgo1-ossl3.5.0

Regressions:

alloc regression: MLDSASign/65-4 [B/op] +0.04% (p=0.003)
alloc regression: MLDSASignExternalMu/87-4 [B/op] +0.03% (p=0.015)

📁 Full results

ubuntu-24.04-arm-go1.26-cgo1-ossl3.0.13 · results
ubuntu-24.04-arm-go1.26-cgo1-ossl3.1.5 · results
ubuntu-24.04-arm-go1.26-cgo1-ossl3.2.1 · results
ubuntu-24.04-arm-go1.26-cgo1-ossl3.3.1 · results

ubuntu-24.04-arm-go1.26-cgo1-ossl3.4.0

Regressions:

alloc regression: PBKDF2HMACSHA256-4 [B/op] +0.47% (p=0.001)

📁 Full results

ubuntu-24.04-arm-go1.26-cgo1-ossl3.5.0 · results
ubuntu-latest-go1.25-cgo1-azl3 · results
ubuntu-latest-go1.26-cgo1-azl3 · results

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