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

Breakpoint not hit when debugging in a docker container built with --platform linux/amd64 ("input/output error") #3616

Closed
avishay28 opened this issue Jan 1, 2024 · 2 comments

Comments

@avishay28
Copy link

avishay28 commented Jan 1, 2024

I followed this tutorial to debug a go application inside a docker container:
https://blog.jetbrains.com/go/2020/05/06/debugging-a-go-application-inside-a-docker-container/

Everything works fine, however if I try to add --platform linux/amd64 as a build option (I need to add it for some reason), the debugging not working, when I place a breakpoint and run the debugger it becomes gray, and when I hover over it I see "input/output" error message
These are the last messages I see in the logs:

2024-01-01T13:00:49Z debug layer=rpc <- RPCServer.CreateBreakpoint(rpc2.CreateBreakpointIn{"Breakpoint":{"id":0,"name":"","addr":0,"addrs":null,"addrpid":null,"file":"/dockerdev/main.go","line":9,"ExprString":"","Cond":"","HitCond":"","HitCondPerG":false,"continue":false,"traceReturn":false,"goroutine":false,"stacktrace":0,"LoadArgs":null,"LoadLocals":null,"WatchExpr":"","WatchType":0,"hitCount":null,"totalHitCount":0,"disabled":false},"LocExpr":"","SubstitutePathRules":null,"Suspended":false})
2024-01-01T13:00:49Z debug layer=rpc -> *rpc2.CreateBreakpointOut{"Breakpoint":{"id":0,"name":"","addr":0,"addrs":null,"addrpid":null,"file":"","line":0,"ExprString":"","Cond":"","HitCond":"","HitCondPerG":false,"continue":false,"traceReturn":false,"goroutine":false,"stacktrace":0,"LoadArgs":null,"LoadLocals":null,"WatchExpr":"","WatchType":0,"hitCount":null,"totalHitCount":0,"disabled":false}} error: "input/output error"
2024-01-01T13:00:49Z debug layer=rpc (async 9) <- RPCServer.State(rpc2.StateIn{"NonBlocking":true})
2024-01-01T13:00:49Z debug layer=rpc (async 9) -> rpc2.StateOut{"State":{"Pid":17,"TargetCommandLine":"/usr/bin/rosetta-wrapper /server /server","Running":false,"Recording":false,"CoreDumping":false,"currentThread":{"id":17,"pc":0,"file":"","line":0,"goroutineID":0,"ReturnValues":null,"CallReturn":false},"Threads":[{"id":17,"pc":0,"file":"","line":0,"goroutineID":0,"ReturnValues":null,"CallReturn":false}],"NextInProgress":false,"WatchOutOfScope":null,"exited":false,"exitStatus":0,"When":""}} error: ""
2024-01-01T13:00:49Z debug layer=rpc (async 10) <- RPCServer.Command(api.DebuggerCommand{"name":"continue","ReturnInfoLoadConfig":null})
2024-01-01T13:00:49Z debug layer=debugger continuing
2024-01-01T13:00:49Z debug layer=debugger ContinueOnce
2024-01-01T13:00:49Z debug layer=rpc (async 10) -> <nil>null error: "input/output error"

Dockerfile:

# Compile stage
FROM golang:1.21 AS build-env

RUN go install github.com/go-delve/delve/cmd/dlv@latest

ADD . /dockerdev
WORKDIR /dockerdev

RUN go build -gcflags="all=-N -l" -o /server

# Final stage
FROM ubuntu:22.04

RUN mkdir -p /tmp/log

EXPOSE 8089 40000

WORKDIR /
COPY --from=build-env /go/bin/dlv /
COPY --from=build-env /server /

CMD ["/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "--log","--log-dest", "/tmp/log/dlv", "--log-output", "debugger,rpc,dap", "exec", "/server"]

  1. What version of Delve are you using (dlv version)?
    Version: 1.22.0

  2. What version of Go are you using? (go version)?
    go version go1.21.5 linux/amd64

  3. What operating system and processor architecture are you using?
    Host machine is apple silicon m1 (darwin/arm64), docker machine is pulled from ubuntu:20.04 (linux/amd64)

  4. What did you do?
    Tried to debug go app inside a docker container when image built with --platform linux/amd64, running on apple M1

  5. What did you expect to see?
    The breakpoint to hit

  6. What did you see instead?
    Breakpoint becomes gray, and debugger is not working

@aarzilli
Copy link
Member

aarzilli commented Jan 1, 2024

It used to be that it wasn't possible at all to start delve inside an amd64 docker container running under arm64. It looks like they have made some progress but not enough. This is a docker bug.

Closing, duplicate of #2910

@aarzilli aarzilli closed this as completed Jan 1, 2024
@aarzilli
Copy link
Member

aarzilli commented Jan 1, 2024

See also docker/for-mac#6921 for a similar bug reported against docker and gdb.

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

No branches or pull requests

2 participants