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.mmap regression from Julia 1.10.0 to 1.10.1 #54203

Open
JakeZw opened this issue Apr 22, 2024 · 5 comments
Open

Mmap.mmap regression from Julia 1.10.0 to 1.10.1 #54203

JakeZw opened this issue Apr 22, 2024 · 5 comments

Comments

@JakeZw
Copy link

JakeZw commented Apr 22, 2024

I use the Raspberry PI for some work. This includes using the Package BaremetalPi to set pins high or low. This all works well with Julia 1.10.0 but not with 1.10.1. This is explained in more detail on discourse here.

The problem lies in Mmap as explained in Post 6 of the discourse link and repeated here. All commands were given on a Raspberry PI 4 with 8 Gig RAM. Julia was installed using Juliaup.

The output from 1.10.0 which is working is:

julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (aarch64-linux-gnu)
  CPU: 4 Ã Cortex-A72
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, cortex-a72)
  Threads: 1 on 4 virtual cores

julia> using Mmap

julia> io = open("/dev/gpiomem", "w+")
IOStream(<file /dev/gpiomem>)

julia> gpiomap = Mmap.mmap(io, Vector{UInt32}, (1024,), 0, grow=false)
1024-element Vector{UInt32}:
 0x21200900
 0x00040264
 0x12040000
 0x3fffffff
 0x00000064
 0x00000000
 0x00000000
 0x6770696f
 0x6770696f
 0x6770696f
          â®
 0x6770696f
 0x6770696f
 0x6770696f
 0x6770696f
 0x6770696f
 0x6770696f
 0x6770696f
 0x6770696f
 0x6770696f

And from 1.10.1 which errors is:

julia> versioninfo()
Julia Version 1.10.1
Commit 7790d6f0641 (2024-02-13 20:41 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (aarch64-linux-gnu)
  CPU: 4 Ã Cortex-A72
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, cortex-a72)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)

julia> using Mmap

julia> io = open("/dev/gpiomem", "w+")
IOStream(<file /dev/gpiomem>)

julia> gpiomap = Mmap.mmap(io, Vector{UInt32}, (1024,), 0, grow=false)
ERROR: IOError: filesize: Illegal seek for <file /dev/gpiomem>
Stacktrace:
 [1] filesize(s::IOStream)
   @ Base ./iostream.jl:226
 [2] mmap(io::IOStream, ::Type{Vector{UInt32}}, dims::Tuple{Int64}, offset::Int64; grow::Bool, shared::Bool)
   @ Mmap ~/.julia/juliaup/julia-1.10.1+0.aarch64.linux.gnu/share/julia/stdlib/v1.10/Mmap/src/Mmap.jl:215
 [3] top-level scope
   @ REPL[4]:1

Version 1.10.2 has the same issue, I have not tested on 1.10.3 release candidate.

@mkitti
Copy link
Contributor

mkitti commented Apr 22, 2024

This seems likely due to #44354 which introduced a call to filesize.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Apr 22, 2024

That was a known correctness bug with the implementation of filesize: #48667

@ronisbr
Copy link
Sponsor Member

ronisbr commented May 8, 2024

Hi!

Is there any known workaround? In the current state, we cannot use Julia to command the Raspberry Pi's IOs using the package BaremetalPi.jl.

@StefanKarpinski
Copy link
Sponsor Member

IMO, we shouldn't be breaking things like this in patch releases, even if it was a bug.

@StefanKarpinski StefanKarpinski added the status:triage This should be discussed on a triage call label May 8, 2024
@tecosaur
Copy link
Contributor

tecosaur commented May 9, 2024

From triage:

  • There's an optimisation to filesize that relies on seeking (see faster filesize and read(::IOStream) #35925)
  • When the IO isn't seekable, this fails
  • We need to handle the seek failure case properly, and fallback on calling stat

@LilithHafner LilithHafner removed the status:triage This should be discussed on a triage call label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants