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

🐛 fix bus error on smaller readonly file in unix #44354

Merged
merged 10 commits into from
Aug 21, 2023
Prev Previous commit
Next Next commit
try keep old behaviror for 🍎
  • Loading branch information
xgdgsc authored and vtjnash committed Jul 18, 2023
commit 67bab23ec15fde7d395404c8189891c3b8a1fe88
9 changes: 7 additions & 2 deletions stdlib/Mmap/src/Mmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ function mmap(io::IO,
file_desc = gethandle(io)
szfile = convert(Csize_t, len + offset)
requestedSizeLarger = false
if !(io isa Mmap.Anonymous || Sys.isapple())
requestedSizeLarger = szfile > filesize(io)
if !(io isa Mmap.Anonymous)
@static if !Sys.isapple()
requestedSizeLarger = szfile > filesize(io)
end
end
# platform-specific mmapping
@static if Sys.isunix()
Expand All @@ -227,6 +229,9 @@ function mmap(io::IO,
throw(ArgumentError("unable to increase file size to $szfile due to read-only permissions"))
end
end
@static if Sys.isapple()
iswrite && grow && grow!(io, offset, len)
end
# 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