Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgo: malformed DWARF TagVariable entry [1.18 backport] #57044

Closed
gopherbot opened this issue Dec 2, 2022 · 5 comments
Closed

cgo: malformed DWARF TagVariable entry [1.18 backport] #57044

gopherbot opened this issue Dec 2, 2022 · 5 comments
Labels
CherryPickApproved Used during the release process for point releases
Milestone

Comments

@gopherbot
Copy link

@crazy-max requested issue #53000 to be considered for backport to the next 1.18 minor release.

@gopherbot please backport to 1.18.

@gopherbot gopherbot added the CherryPickCandidate Used during the release process for point releases label Dec 2, 2022
@gopherbot gopherbot added this to the Go1.18.10 milestone Dec 2, 2022
@thaJeztah
Copy link
Contributor

^^ to add some context

We started running into this issue after the official docker golang alpine image updated to alpine 3.17, which comes with a newer version of clang (see moby/moby#44570);

With alpine 3.16:

docker run -it --rm golang:1.18.8-alpine3.16 sh -c 'apk add --quiet --no-cache clang && clang --version'
Alpine clang version 13.0.1
Target: aarch64-alpine-linux-musl
Thread model: posix
InstalledDir: /usr/bin

With alpine 3.17:

docker run -it --rm golang:1.18.8-alpine3.17 sh -c 'apk add --quiet --no-cache clang && clang --version'
Alpine clang version 15.0.6
Target: aarch64-alpine-linux-musl
Thread model: posix
InstalledDir: /usr/bin

If you have docker installed, the issue can be reproduced with this Dockerfile;

ARG ALPINE_VERSION

FROM golang:1.18.8-alpine${ALPINE_VERSION} AS golatest
RUN apk add --no-cache clang lld git musl-dev gcc
WORKDIR /containerd
RUN set -ex \
 && git clone https://github.com/containerd/containerd.git . \
 && git fetch origin \
 && git checkout -q v1.5.11 \
 && CGO_ENABLED=1 CC=clang go build -tags no_btrfs ./cmd/containerd

With alpine 3.16 (clang 13), it passes;

docker build -t example --build-arg ALPINE_VERSION=3.16 .
...

And with alpine 3.17 (clang 15), it fails:

docker build -t example --build-arg ALPINE_VERSION=3.17 .
...
 > [4/4] RUN set -ex  && git clone https://github.com/containerd/containerd.git .  && git fetch origin  && git checkout -q v1.5.11  && CGO_ENABLED=1 CC=clang go build -tags no_btrfs ./cmd/containerd:
#8 0.261 + git clone https://github.com/containerd/containerd.git .
#8 0.271 Cloning into '.'...
#8 15.91 + git fetch origin
#8 16.44 + git checkout -q v1.5.11
#8 17.02 + CGO_ENABLED=1 CC=clang go build -tags no_btrfs ./cmd/containerd
#8 28.33 # github.com/miekg/pkcs11
#8 28.33 cgo: malformed DWARF TagVariable entry
------
process "/bin/sh -c set -ex  && git clone https://github.com/containerd/containerd.git .  && git fetch origin  && git checkout -q v1.5.11  && CGO_ENABLED=1 CC=clang go build -tags no_btrfs ./cmd/containerd" did not complete successfully: exit code: 2

We noticed that #53013 (https://go.dev/cl/454415 ) was accepted to be backported, which seems related, so we would like to request https://go.dev/cl/406816 to be backported as well.

@ianlancetaylor
Copy link
Contributor

This seems fine to me.

thaJeztah pushed a commit to thaJeztah/go that referenced this issue Dec 3, 2022
https://reviews.llvm.org/D123534 is emitting DW_TAG_variable's
that don't have a DW_AT_name. This is allowed in the DWARF
standard. It is adding DIE's for string literals for better
symbolization on buffer overlows etc on these strings. They
no associated name because they are not user provided variables.

Fixes golang#57044
Updates golang#53000

Change-Id: I2cf063160508687067c7672cef0517bccd707d7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/406816
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
(cherry picked from commit e66f895)
@gopherbot
Copy link
Author

Change https://go.dev/cl/455055 mentions this issue: [release-branch.go1.18] cmd/cgo: allow DW_TAG_variable's with no name

@gopherbot
Copy link
Author

Change https://go.dev/cl/455056 mentions this issue: [release-branch.go1.18] cmd/cgo: allow DW_TAG_variable's with no name

@gopherbot
Copy link
Author

Closed by merging e6adccb to release-branch.go1.18.

gopherbot pushed a commit that referenced this issue Dec 19, 2022
https://reviews.llvm.org/D123534 is emitting DW_TAG_variable's that don't have a DW_AT_name. This is allowed in the DWARF standard. It is adding DIE's for string literals for better symbolization on buffer overlows etc on these strings. They no associated name because they are not user provided variables.

Fixes #57044
Updates #53000

Change-Id: I2cf063160508687067c7672cef0517bccd707d7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/406816
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
(cherry picked from commit e66f895)

Change-Id: I2cf063160508687067c7672cef0517bccd707d7b
GitHub-Last-Rev: 32208e4
GitHub-Pull-Request: #57067
Reviewed-on: https://go-review.googlesource.com/c/go/+/455055
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CherryPickApproved Used during the release process for point releases
Projects
None yet
Development

No branches or pull requests

4 participants