JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.65k stars 5.48k forks source link

Mmap.mmap regression from Julia 1.10.0 to 1.10.1 #54203

Closed JakeZw closed 1 month ago

JakeZw commented 6 months ago

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 commented 6 months ago

This seems likely due to https://github.com/JuliaLang/julia/pull/44354 which introduced a call to filesize.

vtjnash commented 6 months ago

That was a known correctness bug with the implementation of filesize: https://github.com/JuliaLang/julia/issues/48667

ronisbr commented 5 months ago

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 commented 5 months ago

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

tecosaur commented 5 months ago

From triage:

JakeZw commented 3 months ago

Ronan,

I was listening to your talks at JuliaCon in Eindhoven and had a thought.

Julia embedded in another environment – there is a very nice example in a package called Sigview https://sigview.com/ . If you scroll down to the news section, you can see what they are doing. I have not used it but if I had the NI data acquisition modules I would. It appears to be a nice package.

Also I think your example used Forward Polish Notation. I use RPN on my HP calculator and really like it there.

For the benefit of your managers, I am using BareMetalPi in one of my applications. This application is public but not registered. You can find it on github https://github.com/Spectrum-Tec/MccDaqHats.jl . Note that only the MCC172 card is supported though the code for the other available cards has been started (just the Clang translation). Also the dll currently is outdated, and does not work for Pi 5. We will need to update that.

Jake Zwart | Principal

Spectrum Technologies, Ontario (t) 905-659-6478 (m) 289-680-8557 http://www.spectrum-tec.com www.spectrum-tec.com

n Github.

ronisbr commented 3 months ago

Hi @JakeZw!

Thanks for the information!

ronisbr commented 1 month ago

Bump! Unfortunately, low-level access to Raspberry Pi's devices is completely broken after 1.10.1 :(

IanButterworth commented 1 month ago

I think this is what's been suggested? https://github.com/JuliaLang/julia/pull/55641

JakeZw commented 1 month ago

Issue 55641 does not seem to correspond to what I am seeing. More details herehttps://github.com/JuliaLang/julia/pull/55641. To the best of my knowledge it is not the issue.

I note that Mmap.mmap has changed between 1.10.0 and 1.10.1 and again for 1.12.1 which has a reduced argument list. Could this be the source of the problem?