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

Mmap bus error #28245

Open
quinnj opened this issue Jul 23, 2018 · 10 comments · Fixed by #44354
Open

Mmap bus error #28245

quinnj opened this issue Jul 23, 2018 · 10 comments · Fixed by #44354
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@quinnj
Copy link
Member

quinnj commented Jul 23, 2018

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.7.0-beta2.84 (2018-07-23 19:53 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 10002fcb5e* (0 days old master)
|__/                   |  x86_64-apple-darwin16.7.0

julia> using Mmap

julia> a = Mmap.mmap("foo2", Vector{NTuple{1, Int8}}, 1, 0)
1-element Array{Tuple{Int8},1}:
Bus error: 10

Also happens for simple structs like struct Wrapper; x::Int; end. I plan on taking a look at this to see what's going on, but if anyone else has any ideas, please share in the mean time.

@JeffBezanson
Copy link
Sponsor Member

Works for me.

@jpsamaroo
Copy link
Member

I also got a Bus error (on Linux, Julia Version 0.7.0-beta2.78), but that was because the file was empty. Adding 10M to the file with dd fixed it. If that doesn't work, you could try running under strace (or whatever the equivalent is on OSX, dtrace maybe?).

@xgdgsc
Copy link
Contributor

xgdgsc commented Jan 9, 2020

I get bus error if specified shape larger than the file size. Julia would crash. Is it possible to make it not crash the session and only report an error? I think it could check filesize first.

@xgdgsc
Copy link
Contributor

xgdgsc commented Jan 10, 2020

using Mmap
A = rand(1:0.5:20, 5, 30)
s = open("mmap.bin", "w+")
write(s, A)
close(s)
B = Mmap.mmap(open("mmap.bin"), Matrix{Float64}, (4096,30))

This would crash with Bus Error on Ubuntu 16.04 with julia 1.3.1 . While on Win 10 it only prints an error.

@Moelf
Copy link
Sponsor Contributor

Moelf commented Feb 25, 2022

Does this still crash for some people?

@xgdgsc
Copy link
Contributor

xgdgsc commented Feb 25, 2022

The original poster code doesn' t crash. My code in the comment above still crashes in Ubuntu 20.04, julia 1.6 and 1.7.

@ViralBShah ViralBShah added the mac Affects only macOS label Feb 25, 2022
@vtjnash
Copy link
Sponsor Member

vtjnash commented Feb 25, 2022

As mentioned above #28245 (comment), there is a missing call to open(identity, "foo2", "w") in the MWE

@vtjnash vtjnash reopened this Feb 25, 2022
@vtjnash vtjnash added bug Indicates an unexpected problem or unintended behavior and removed mac Affects only macOS labels Nov 8, 2022
@davidbp
Copy link

davidbp commented Nov 8, 2022

On 1.8 I still get weird errors. For example, depending on which position I access from the memmapped file the code crashes

julia> using Mmap

julia> data = Mmap.mmap("./test.mmap", Matrix{Float32}, (64, 2000_000));

julia> x = data[:,1_00]; #works fine

julia> y = data[:,1_000_000];

signal (10): Bus error: 10
in expression starting at REPL[4]:1
getindex at ./array.jl:925 [inlined]
macro expansion at ./multidimensional.jl:903 [inlined]
macro expansion at ./cartesian.jl:64 [inlined]
_unsafe_getindex! at ./multidimensional.jl:898 [inlined]
_unsafe_getindex at ./multidimensional.jl:889 [inlined]
_getindex at ./multidimensional.jl:875 [inlined]
getindex at ./abstractarray.jl:1241
unknown function (ip: 0x10851c1df)
ijl_apply_generic at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.8.dylib (unknown line)
do_call at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.8.dylib (unknown line)
eval_body at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_interpret_toplevel_thunk at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_toplevel_eval_flex at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_toplevel_eval_flex at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.8.dylib (unknown line)
ijl_toplevel_eval_in at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.8.dylib (unknown line)
eval at ./boot.jl:368 [inlined]
eval_user_input at /Users/administrator/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-aarch64-1.0/build/default-macmini-aarch64-1-0/julialang/julia-release-1-dot-8/usr/share/julia/stdlib/v1.8/REPL/src/REPL.jl:151
repl_backend_loop at /Users/administrator/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-aarch64-1.0/build/default-macmini-aarch64-1-0/julialang/julia-release-1-dot-8/usr/share/julia/stdlib/v1.8/REPL/src/REPL.jl:247
start_repl_backend at /Users/administrator/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-aarch64-1.0/build/default-macmini-aarch64-1-0/julialang/julia-release-1-dot-8/usr/share/julia/stdlib/v1.8/REPL/src/REPL.jl:232
#run_repl#47 at /Users/administrator/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-aarch64-1.0/build/default-macmini-aarch64-1-0/julialang/julia-release-1-dot-8/usr/share/julia/stdlib/v1.8/REPL/src/REPL.jl:369
run_repl at /Users/administrator/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-aarch64-1.0/build/default-macmini-aarch64-1-0/julialang/julia-release-1-dot-8/usr/share/julia/stdlib/v1.8/REPL/src/REPL.jl:355
jfptr_run_repl_67919 at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
ijl_apply_generic at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.8.dylib (unknown line)
#966 at ./client.jl:419
jfptr_YY.966_42132 at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
ijl_apply_generic at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_f__call_latest at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.8.dylib (unknown line)
#invokelatest#2 at ./essentials.jl:729 [inlined]
invokelatest at ./essentials.jl:726 [inlined]
run_main_repl at ./client.jl:404
exec_options at ./client.jl:318
_start at ./client.jl:522
jfptr__start_58825 at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
ijl_apply_generic at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.8.dylib (unknown line)
true_main at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.8.dylib (unknown line)
jl_repl_entrypoint at /Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.8.dylib (unknown line)
Allocations: 2906 (Pool: 2894; Big: 12); GC: 0
Bus error: 10

@elextr
Copy link

elextr commented Nov 8, 2022

Just a note that the Linux mmap documentation says SIGBUS occurs when an attempt is made to access pages of the mapping beyond the size of the file.

vtjnash added a commit that referenced this issue Aug 21, 2023
Fixes: #28245
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Co-authored-by: Stefan Karpinski <stefan@karpinski.org>
@vtjnash vtjnash reopened this Aug 21, 2023
@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 21, 2023

Still a bug on macOS

KristofferC pushed a commit that referenced this issue Feb 6, 2024
Fixes: #28245
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Co-authored-by: Stefan Karpinski <stefan@karpinski.org>
(cherry picked from commit ead627e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants