Skip to content

Commit

Permalink
πŸ› fix bus error on smaller readonly file in unix
Browse files Browse the repository at this point in the history
  • Loading branch information
xgdgsc authored and vtjnash committed Nov 8, 2022
1 parent 5a323a6 commit 817a8ee
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions stdlib/Mmap/src/Mmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ function mmap(io::IO,
@static if Sys.isunix()
prot, flags, iswrite = settings(file_desc, shared)
iswrite && grow && grow!(io, offset, len)
!iswrite && mmaplen > filesize(io) && throw(ArgumentError("unable to mmap file size smaller than $mmaplen due to read-only permissions. Please check your dims"))
# mmap the file
ptr = ccall(:jl_mmap, Ptr{Cvoid}, (Ptr{Cvoid}, Csize_t, Cint, Cint, RawFD, Int64),
C_NULL, mmaplen, prot, flags, file_desc, offset_page)
Expand Down

0 comments on commit 817a8ee

Please sign in to comment.