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 problem? ([Could not launch program: decoding dwarf section info at offset 0x0: too short]) #79

Closed
quarnster opened this issue Mar 9, 2015 · 13 comments

Comments

@quarnster
Copy link

11:59 ~/code/go $ cat hello.go
package main

// #include <stdio.h>
// #include <stdlib.h>
// static void hack(char *str) { printf("%s", str); }
import "C"

import "unsafe"

func main() {
        cstr := C.CString("hello world!\n")
        defer C.free(unsafe.Pointer(cstr))
        C.hack(cstr)
}
11:59 ~/code/go $ go build hello.go
11:59 ~/code/go $ dlv ./hello
[Could not launch program: decoding dwarf section info at offset 0x0: too short]
11:59 ~/code/go $
dlv
Delve version 0.5.0.beta

flags:
  -v - Print version

Invoke with the path to a binary:

  dlv ./path/to/prog

or use the following commands:
  run - Build, run, and attach to program
  attach - Attach to running process

12:00 ~/code/go $ dlv -v -
flag provided but not defined: -v
Usage of dlv:
12:00 ~/code/go $ go version
go version go1.4 darwin/amd64
12:00 ~/code/go $ uname -a
Darwin Thunder 14.1.0 Darwin Kernel Version 14.1.0: Mon Dec 22 23:10:38 PST 2014; root:xnu-2782.10.72~2/RELEASE_X86_64 x86_64
12:01 ~/code/go $
@quarnster
Copy link
Author

Appears to be related to Go#8973, building with go build -ldflags="-linkmode=internal" appears to work just fine.

Feel free to close this issue if you see nothing you'd like to fix here.

@derekparker
Copy link
Member

Thanks, this surfaced another issue of the -v flag not working, fixed now.

I'll keep this issue open because I can probably get a fix in to Delve to handle this until 1.5 lands.

Also, it's preferred to use dlv run over building yourself, simply because run compiles the program to be a bit more debugger friendly.

@ahl
Copy link

ahl commented Aug 14, 2016

I just hit this on c3ade94 (
could not attach to pid 39933: decoding dwarf section info at offset 0x0: too short

Even more concerning is that dlv killed the process I was trying to debug.

@aarzilli
Copy link
Member

@ahl do you have steps we can follow to reproduce this or a binary to examine?

@ahl
Copy link

ahl commented Aug 16, 2016

package main

import "fmt"

func main() {
    for {
        fmt.Println("all work and no play makes jack a dull boy")
    }
}

go run test.go and dlv attach $(pgrep test) on darwin:

could not attach to pid 68703: decoding dwarf section info at offset 0x0: too short

Perhaps you're not supposed to use dlv with go run? Irrespective "do no harm" is job one for a debugger and my process should not end up dead in any circumstance.

This also happens on a non-golang binary. Again, the debugger should never kill target process.

@gabriel
Copy link

gabriel commented Sep 1, 2016

This also happens if you use -ldflags -s to get macOS codesigning to work golang/go#11887

@xsank
Copy link

xsank commented Nov 16, 2016

i use the idea to debug grafana project on windows,but meet the same problem.
could not launch process: decoding dwarf section info at offset 0x0: too short
after i solved this, and success use the dlv debugging, another trouble comes...
image
it always suspend in here from github.com/go-stack/stack/stack.go
here is my usage:

C:\Users\.IntelliJIdea15\config\plugins\Go\lib\dlv\windows\dlv.exe --listen=localhost:51358 --headless=true exec "C:\Program Files (x86)\JetBrains\IntelliJ IDEA 15.0.2\jre\jre\bin\bin\Build main.exe" --
GOROOT=C:/Go
GOPATH=D:/code/mine/go
C:/Go\bin\go.exe build -ldflags -linkmode=internal -o "C:\Program Files (x86)\JetBrains\IntelliJ IDEA 15.0.2\jre\jre\bin\bin\Build main.exe" -gcflags "-N -l" github.com/grafana/grafana/pkg/cmd/grafana-server
API server listening at: 127.0.0.1:51358  

without any warnings. but it just hang there and cannot move on.
IDEA:15.0.2
Go:1.7.3
OS:widnows 7

@aarzilli
Copy link
Member

@xsank: this should be fixed by f6e8fb3 (see #594), update your dlv.

@xsank
Copy link

xsank commented Nov 16, 2016

@aarzilli ,is there any windows release dlv i can use or i have to build it myself?

@xsank
Copy link

xsank commented Nov 16, 2016

thank you for your help! @aarzilli

@aarzilli
Copy link
Member

@sank: you have to build it yourself.

@aambati
Copy link

aambati commented May 17, 2017

I am seeing this error in Visual Studio code Version 1.12.2 (1.12.2) on Mac:

2017/05/17 13:41:33 server.go:73: Using API v1
2017/05/17 13:41:33 debugger.go:97: launching process with args: [./debug.test]
could not launch process: decoding dwarf section info at offset 0x0: too short
Process exiting with code: 1

GOPATH env variable is set and dlv is installed in $GOPATH/bin directory

launch.json looks like this:

{
   "version": "0.2.0",
   "configurations": [
      {
         "name": "go test",
         "type": "go",
         "request": "launch",
         "mode": "test",
         "remotePath": "",
         "port": 5000,
         "host": "127.0.0.1",
         "program": "<set to directory that contains go test files>",
         "env": {},
         "args": [],
         "showLog": true
      }
   ]
}

I have tried adding GOPATH variable to "env" configuration property in launch.json but got the same error. I am using delve version 1.0.0-rc.1

@aarzilli
Copy link
Member

Open a new issue and fill the form.

nclifton pushed a commit to nclifton/delve that referenced this issue Feb 24, 2021
* simplify grpc and worker startup for testing

* do not add a tracer if the rpc host is an empty string

* restored direct use of pgx

* wrong event type used in db setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants