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

Ubuntu, could not launch process: fork/exec ./debug: operation not permitted #515

Closed
ctaggart opened this Issue Apr 26, 2016 · 14 comments

Comments

Projects
None yet
5 participants
@ctaggart
Copy link

ctaggart commented Apr 26, 2016

I'm on Ubuntu 14.04 and I am not sure what I'm doing wrong to get this error when I run dlv debug:

could not launch process: fork/exec ./debug: operation not permitted

I'm simply following the instructions at:
https://github.com/derekparker/delve/wiki/Building#linux

vscode@9d24dfa15aab:~$ cd $GOPATH/src/golang.org/x/tools/cmd/gorename/
vscode@9d24dfa15aab:~/go/src/golang.org/x/tools/cmd/gorename$ go get -v -u github.com/peterh/liner github.com/derekparker/delve/cmd/dlv
github.com/peterh/liner (download)
github.com/derekparker/delve (download)
vscode@9d24dfa15aab:~/go/src/golang.org/x/tools/cmd/gorename$ ls -al $GOPATH/bin/dlv
-rwxr-xr-x 1 vscode vscode 15499304 Apr 26 19:32 /home/vscode/go/bin/dlv
vscode@9d24dfa15aab:~/go/src/golang.org/x/tools/cmd/gorename$ dlv debug
could not launch process: fork/exec ./debug: operation not permitted
vscode@9d24dfa15aab:~/go/src/golang.org/x/tools/cmd/gorename$ go version
go version go1.6.2 linux/amd64
vscode@9d24dfa15aab:~/go/src/golang.org/x/tools/cmd/gorename$ dlv version
Delve Debugger
Version: 0.11.0-alpha
Build: 
vscode@9d24dfa15aab:~/go/src/golang.org/x/tools/cmd/gorename$ uname -a
Linux 9d24dfa15aab 4.4.6 #1 SMP Mon Apr 18 19:18:15 UTC 2016 x86_64 GNU/Linux
@derekparker

This comment has been minimized.

Copy link
Member

derekparker commented Apr 26, 2016

The updated install instructions for Linux now live here. Can you verify that after following those directions you still experience this issue? Try using the make install command from within the repo.

I'm running Ubuntu 16.04 and Go 1.6.2 and cannot reproduce with the gorename cmd.

@ctaggart

This comment has been minimized.

Copy link

ctaggart commented Apr 26, 2016

Same result with https://github.com/derekparker/delve/blob/master/Documentation/installation/linux/install.md.

vscode@9d24dfa15aab:~/go/src/golang.org/x/tools/cmd/gorename$ rm -rf $GOPATH/src/github.com/derekparker/
vscode@9d24dfa15aab:~/go/src/golang.org/x/tools/cmd/gorename$ go get github.com/derekparker/delve/cmd/dlv
vscode@9d24dfa15aab:~/go/src/golang.org/x/tools/cmd/gorename$ dlv debug
could not launch process: fork/exec ./debug: operation not permitted

or

vscode@9d24dfa15aab:~/go/src/golang.org/x/tools/cmd/gorename$ rm ~/go/bin/dlv 
vscode@9d24dfa15aab:~/go/src/golang.org/x/tools/cmd/gorename$ dlv debug
-su: /home/vscode/go/bin/dlv: No such file or directory
vscode@9d24dfa15aab:~/go/src/golang.org/x/tools/cmd/gorename$ go get github.com/derekparker/delve/cmd/dlv
vscode@9d24dfa15aab:~/go/src/golang.org/x/tools/cmd/gorename$ dlv debug
could not launch process: fork/exec ./debug: operation not permitted
@derekparker

This comment has been minimized.

Copy link
Member

derekparker commented Apr 26, 2016

I assume from your example output that you are within the ~/go/src/golang.org/x/tools/cmd/gorename directory, which should contain main.go representing the main package, correct?

Can you run file $(which dlv) and paste the output, please?

@ctaggart

This comment has been minimized.

Copy link

ctaggart commented Apr 26, 2016

vscode@9d24dfa15aab:~/go/src/golang.org/x/tools/cmd/gorename$ ls
main.go
vscode@9d24dfa15aab:~/go/src/golang.org/x/tools/cmd/gorename$ file $(which dlv)
-su: file: command not found`
@derekparker

This comment has been minimized.

Copy link
Member

derekparker commented Apr 26, 2016

@ctaggart and if you run go build -gcflags="-N -l" within that dir, are you able to run the resulting binary?

@ctaggart

This comment has been minimized.

Copy link

ctaggart commented Apr 26, 2016

vscode@18a88cf9c29e:~/go/src/golang.org/x/tools/cmd/gorename$ go build -ldflags="-N -l"
# golang.org/x/tools/cmd/gorename
flag provided but not defined: -N
usage: link [options] main.o
  -B note
        add an ELF NT_GNU_BUILD_ID note when using ELF
  -C    check Go calls to C code
  -D address
        set data segment address (default -1)
  -E entry
        set entry symbol name
  -H type
        set header type
  -I linker
        use linker as ELF dynamic linker
  -L directory
        add specified directory to library path
  -R quantum
        set address rounding quantum (default -1)
  -T address
        set text segment address (default -1)
  -V    print version and exit
  -X definition
        add string value definition of the form importpath.name=value
  -a    disassemble output
  -buildid id
        record id as Go toolchain build id
  -buildmode mode
        set build mode
  -c    dump call graph
  -cpuprofile file
        write cpu profile to file
  -d    disable dynamic executable
  -extar string
        archive program for buildmode=c-archive
  -extld linker
        use linker when linking in external mode
  -extldflags flags
        pass flags to external linker
  -f    ignore version mismatch
  -g    disable go package data checks
  -h    halt on error
  -installsuffix suffix
        set package directory suffix
  -k symbol
        set field tracking symbol
  -libgcc string
        compiler support lib for internal linking; use "none" to disable
  -linkmode mode
        set link mode (internal, external, auto)
  -linkshared
        link against installed Go shared libraries
  -memprofile file
        write memory profile to file
  -memprofilerate rate
        set runtime.MemProfileRate to rate
  -msan
        enable MSan interface
  -n    dump symbol table
  -o file
        write output to file
  -r path
        set the ELF dynamic linker search path to dir1:dir2:...
  -race
        enable race detector
  -s    disable symbol table
  -shared
        generate shared object (implies -linkmode external)
  -tmpdir directory
        use directory for temporary files
  -u    reject unsafe packages
  -v    print link trace
  -w    disable DWARF generation
@derekparker

This comment has been minimized.

Copy link
Member

derekparker commented Apr 26, 2016

@ctaggart updated the above comment, I meant -gcflags not -ldflags, please try again with -gcflags, sorry.

@ctaggart

This comment has been minimized.

Copy link

ctaggart commented Apr 26, 2016

Yes.

vscode@18a88cf9c29e:~/go/src/golang.org/x/tools/cmd/gorename$ go build -gcflags="-N -l"
vscode@18a88cf9c29e:~/go/src/golang.org/x/tools/cmd/gorename$ ls          
gorename  main.go
vscode@18a88cf9c29e:~/go/src/golang.org/x/tools/cmd/gorename$ gorename 
gorename: precise type-safe renaming of identifiers in Go source code.

Usage:

 gorename (-from <spec> | -offset <file>:#<byte-offset>) -to <name> [-force]

You must specify the object (named entity) to rename using the -offset
or -from flag.  Exactly one must be specified.

Flags:

-offset    specifies the filename and byte offset of an identifier to rename.
           This form is intended for use by text editors.

-from      specifies the object to rename using a query notation;
           This form is intended for interactive use at the command line.
           A legal -from query has one of the following forms:

  "encoding/json".Decoder.Decode        method of package-level named type
  (*"encoding/json".Decoder).Decode     ditto, alternative syntax
  "encoding/json".Decoder.buf           field of package-level named struct type
  "encoding/json".HTMLEscape            package member (const, func, var, type)
  "encoding/json".Decoder.Decode::x     local object x within a method
  "encoding/json".HTMLEscape::x         local object x within a function
  "encoding/json"::x                    object x anywhere within a package
  json.go::x                            object x within file json.go

           Double-quotes must be escaped when writing a shell command.
           Quotes may be omitted for single-segment import paths such as "fmt".

           For methods, the parens and '*' on the receiver type are both
           optional.

           It is an error if one of the ::x queries matches multiple
           objects.

-to        the new name.

-force     causes the renaming to proceed even if conflicts were reported.
           The resulting program may be ill-formed, or experience a change
           in behaviour.

           WARNING: this flag may even cause the renaming tool to crash.
           (In due course this bug will be fixed by moving certain
           analyses into the type-checker.)

-d         display diffs instead of rewriting files

-v         enables verbose logging.

gorename automatically computes the set of packages that might be
affected.  For a local renaming, this is just the package specified by
-from or -offset, but for a potentially exported name, gorename scans
the workspace ($GOROOT and $GOPATH).

gorename rejects renamings of concrete methods that would change the
assignability relation between types and interfaces.  If the interface
change was intentional, initiate the renaming at the interface method.

gorename rejects any renaming that would create a conflict at the point
of declaration, or a reference conflict (ambiguity or shadowing), or
anything else that could cause the resulting program not to compile.


Examples:

$ gorename -offset file.go:#123 -to foo

  Rename the object whose identifier is at byte offset 123 within file file.go.

$ gorename -from '"bytes".Buffer.Len' -to Size

  Rename the "Len" method of the *bytes.Buffer type to "Size".

---- TODO ----

Correctness:
- handle dot imports correctly
- document limitations (reflection, 'implements' algorithm).
- sketch a proof of exhaustiveness.

Features:
- support running on packages specified as *.go files on the command line
- support running on programs containing errors (loader.Config.AllowErrors)
- allow users to specify a scope other than "global" (to avoid being
  stuck by neglected packages in $GOPATH that don't build).
- support renaming the package clause (no object)
- support renaming an import path (no ident or object)
  (requires filesystem + SCM updates).
- detect and reject edits to autogenerated files (cgo, protobufs)
  and optionally $GOROOT packages.
- report all conflicts, or at least all qualitatively distinct ones.
  Sometimes we stop to avoid redundancy, but
  it may give a disproportionate sense of safety in -force mode.
- support renaming all instances of a pattern, e.g.
  all receiver vars of a given type,
  all local variables of a given type,
  all PkgNames for a given package.
- emit JSON output for other editors and tools.
@ctaggart

This comment has been minimized.

Copy link

ctaggart commented Apr 26, 2016

I tagged what I currently have as 0.0.2. You can reproduce and troubleshoot directly on the docker image. Here are the steps:

docker run --rm -it ctaggart/golang-vscode:0.0.2 su - vscode
cd $GOPATH/src/golang.org/x/tools/cmd/gorename/
dlv debug
Camerons-iMac:golang-vscode cameron$ docker run --rm -it ctaggart/golang-vscode:0.0.2 su - vscode
Unable to find image 'ctaggart/golang-vscode:0.0.2' locally
0.0.2: Pulling from ctaggart/golang-vscode
efd26ecc9548: Already exists 
a3ed95caeb02: Pull complete 
d1784d73276e: Already exists 
72e581645fc3: Already exists 
01ce90e06b06: Already exists 
dd49ac13b118: Already exists 
3f4ffd08203e: Already exists 
5852efbc7938: Already exists 
6f409912964d: Pull complete 
62f278e9fb96: Pull complete 
Digest: sha256:84c879adf8302aaacf9a2ac72be42157ae0bc2e6b7d93741fa9019cc03c5879a
Status: Downloaded newer image for ctaggart/golang-vscode:0.0.2
vscode@793f6aa806dd:~$ cd $GOPATH/src/golang.org/x/tools/cmd/gorename/
vscode@793f6aa806dd:~/go/src/golang.org/x/tools/cmd/gorename$ dlv debug
could not launch process: fork/exec ./debug: operation not permitted

The relevant build files are:
https://github.com/ctaggart/golang-vscode/blob/master/Dockerfile
https://github.com/ctaggart/golang-vscode/blob/master/root/install-vscode-Go.sh

@derekparker

This comment has been minimized.

Copy link
Member

derekparker commented Apr 26, 2016

Alright, so you're running within a Docker container. Docker has security settings preventing ptrace(2) operations by default with in the container. Pass --security-opt=seccomp:unconfined to docker run when starting.

@ctaggart

This comment has been minimized.

Copy link

ctaggart commented Apr 27, 2016

Thank you!

Camerons-iMac:golang-vscode cameron$ docker run --rm -it --security-opt seccomp=unconfined ctaggart/golang-vscode:0.0.2 su - vscode
vscode@64057935aa4e:~$ cd $GOPATH/src/golang.org/x/tools/cmd/gorename/
vscode@64057935aa4e:~/go/src/golang.org/x/tools/cmd/gorename$ dlv debug
Type 'help' for list of commands.
(dlv) 
@jkryanchou

This comment has been minimized.

Copy link

jkryanchou commented Nov 9, 2017

@derekparker awesome, It works.

@e-gautier

This comment has been minimized.

Copy link

e-gautier commented Dec 29, 2017

@derekparker Thank you.

@virtuald

This comment has been minimized.

Copy link

virtuald commented Aug 13, 2018

I ran into this and it took awhile for my google search to find this. Is there a way dlv can know that it's running into this particular error and output a helpful hint?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment