docker-library / julia

Docker Official Image packaging for julia

Home Page:http://julialang.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Segmentation fault inside Docker

BenjaminGalliot opened this issue Β· comments

Hello,

It is related to this issue from FilePaths.

It seems there is a problem in Docker (latest julia) with several functions, like isfile and isdir.

julia> using FilePaths
[ Info: Precompiling FilePaths [8fc22ac5-c921-52a6-82fd-178b2807b824]
julia> isdir(".")
true
julia> isdir(p".")
signal (11): Segmentation fault
in expression starting at REPL[4]:1
unsafe_load at ./pointer.jl:105 [inlined]
unsafe_load at ./pointer.jl:105 [inlined]
User at /root/.julia/packages/FilePathsBase/oi7XZ/src/libc.jl:63 [inlined]
User at /root/.julia/packages/FilePathsBase/oi7XZ/src/libc.jl:86
Status at /root/.julia/packages/FilePathsBase/oi7XZ/src/status.jl:21
stat at /root/.julia/packages/FilePathsBase/oi7XZ/src/system.jl:55 [inlined]
mode at /root/.julia/packages/FilePathsBase/oi7XZ/src/system.jl:69 [inlined]
isdir at /root/.julia/packages/FilePathsBase/oi7XZ/src/system.jl:97
unknown function (ip: 0x7f186d0ef58f)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2159 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2323
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1700 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:369
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:458
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:409 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:817
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:911
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:819
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:769
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:848
eval at ./boot.jl:331
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2145 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2323
eval_user_input at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:118 [inlined]
#26 at ./task.jl:358
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2145 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2323
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1700 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:687
unknown function (ip: (nil))
Allocations: 11325876 (Pool: 11324204; Big: 1672); GC: 10

Sincerely.

I'm not actually able to reproduce this: πŸ˜•

$ docker pull julia
Using default tag: latest
latest: Pulling from library/julia
Digest: sha256:af2dffac4f868f62716940f8f74b925f15508a297ba0099e50669fcc6c011dd2
Status: Image is up to date for julia:latest
docker.io/library/julia:latest

$ docker run -it --rm julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.2 (2020-05-23)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> import Pkg; Pkg.add("FilePaths")
    Cloning default registries into `~/.julia`
    Cloning registry from "https://github.com/JuliaRegistries/General.git"
      Added registry `General` to `~/.julia/registries/General`
  Resolving package versions...
  Installed Reexport ────── v0.2.0
  Installed FilePaths ───── v0.8.0
  Installed FilePathsBase ─ v0.6.2
  Installed URIParser ───── v0.4.1
  Installed MacroTools ──── v0.5.5
   Updating `~/.julia/environments/v1.4/Project.toml`
  [8fc22ac5] + FilePaths v0.8.0
   Updating `~/.julia/environments/v1.4/Manifest.toml`
  [8fc22ac5] + FilePaths v0.8.0
  [48062228] + FilePathsBase v0.6.2
  [1914dd2f] + MacroTools v0.5.5
  [189a3867] + Reexport v0.2.0
  [30578b45] + URIParser v0.4.1
  [2a0f44e3] + Base64 
  [ade2ca70] + Dates 
  [8ba89e20] + Distributed 
  [b77e0a4c] + InteractiveUtils 
  [76f85450] + LibGit2 
  [8f399da3] + Libdl 
  [37e2e46d] + LinearAlgebra 
  [56ddb016] + Logging 
  [d6f4376e] + Markdown 
  [44cfe95a] + Pkg 
  [de0858da] + Printf 
  [3fa0cd96] + REPL 
  [9a3f8284] + Random 
  [ea8e919c] + SHA 
  [9e88b42a] + Serialization 
  [6462fe0b] + Sockets 
  [8dfed614] + Test 
  [cf7118a7] + UUIDs 
  [4ec0a83e] + Unicode 

julia> isdir(".")
true

julia> using FilePaths
[ Info: Precompiling FilePaths [8fc22ac5-c921-52a6-82fd-178b2807b824]

julia> isdir(p".")
true

It is true, with the basic command, it works well. I found the command I used (but I still can’t find where I found it, it was to learn Docker).

benjamin@benjamin-pc:~$ docker run --rm -it -v "$PWD":/usr/myapp -w /usr/myapp julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.2 (2020-05-23)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(@v1.4) pkg> add FilePaths
    Cloning default registries into `~/.julia`
    Cloning registry from "https://github.com/JuliaRegistries/General.git"
      Added registry `General` to `~/.julia/registries/General`
  Resolving package versions...
  Installed URIParser ───── v0.4.1
  Installed FilePathsBase ─ v0.6.2
  Installed MacroTools ──── v0.5.5
  Installed Reexport ────── v0.2.0
  Installed FilePaths ───── v0.8.0
   Updating `~/.julia/environments/v1.4/Project.toml`
  [8fc22ac5] + FilePaths v0.8.0
   Updating `~/.julia/environments/v1.4/Manifest.toml`
  [8fc22ac5] + FilePaths v0.8.0
  [48062228] + FilePathsBase v0.6.2
  [1914dd2f] + MacroTools v0.5.5
  [189a3867] + Reexport v0.2.0
  [30578b45] + URIParser v0.4.1
  [2a0f44e3] + Base64 
  [ade2ca70] + Dates 
  [8ba89e20] + Distributed 
  [b77e0a4c] + InteractiveUtils 
  [76f85450] + LibGit2 
  [8f399da3] + Libdl 
  [37e2e46d] + LinearAlgebra 
  [56ddb016] + Logging 
  [d6f4376e] + Markdown 
  [44cfe95a] + Pkg 
  [de0858da] + Printf 
  [3fa0cd96] + REPL 
  [9a3f8284] + Random 
  [ea8e919c] + SHA 
  [9e88b42a] + Serialization 
  [6462fe0b] + Sockets 
  [8dfed614] + Test 
  [cf7118a7] + UUIDs 
  [4ec0a83e] + Unicode 

julia> using FilePaths
[ Info: Precompiling FilePaths [8fc22ac5-c921-52a6-82fd-178b2807b824]

julia> isdir(".")
true

julia> isdir(p".")

signal (11): Segmentation fault
in expression starting at REPL[4]:1
unsafe_load at ./pointer.jl:105 [inlined]
unsafe_load at ./pointer.jl:105 [inlined]
User at /root/.julia/packages/FilePathsBase/oi7XZ/src/libc.jl:63 [inlined]
User at /root/.julia/packages/FilePathsBase/oi7XZ/src/libc.jl:86
Status at /root/.julia/packages/FilePathsBase/oi7XZ/src/status.jl:21
stat at /root/.julia/packages/FilePathsBase/oi7XZ/src/system.jl:55 [inlined]
mode at /root/.julia/packages/FilePathsBase/oi7XZ/src/system.jl:69 [inlined]
isdir at /root/.julia/packages/FilePathsBase/oi7XZ/src/system.jl:97
unknown function (ip: 0x7f664e26858f)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2159 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2323
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1700 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:369
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:458
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:409 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:817
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:911
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:819
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:769
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:848
eval at ./boot.jl:331
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2145 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2323
eval_user_input at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:118 [inlined]
#26 at ./task.jl:358
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2145 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2323
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1700 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:687
unknown function (ip: (nil))
Allocations: 11324828 (Pool: 11323150; Big: 1678); GC: 11

Maybe I missed something trivial…

Sincerely.

Huh, I can reproduce with that, so it must be something to do with the bind mount. Interesting!

Found it -- it's because the directory is owned by your UID:GID, but your UID:GID doesn't exist in /etc/passwd / /etc/group inside the container, so FilePaths apparently segfaults when it tries to look that information up and can't find it.

Adding -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro to my docker run line fixed it.

This could be trivially verified on any host (Docker or not) by doing something like the following:

$ mkdir temp
$ sudo chown 12345:12345 temp # make sure this UID:GID combo is not one defined in /etc/passwd and/or /etc/group
$ julia -e 'using FilePaths; println(isdir(p"temp"))'

Thank you, this problem vanished by your command addition!

... and now that module generates appropriate error messages instead of segfaulting! πŸ₯³ rofinn/FilePathsBase.jl#91