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

@printf crashes with g/G format and non-finite numbers #41631

Closed
mwlidar opened this issue Jul 18, 2021 · 5 comments · Fixed by #41650
Closed

@printf crashes with g/G format and non-finite numbers #41631

mwlidar opened this issue Jul 18, 2021 · 5 comments · Fixed by #41650

Comments

@mwlidar
Copy link

mwlidar commented Jul 18, 2021

@printf("%G", NaN)
ERROR: BoundsError: attempt to access 337-element Vector{UInt8} at index [0]
Stacktrace:
[1] getindex
@ .\array.jl:801 [inlined]
[2] fmt
@ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Printf\src\Printf.jl:428 [inlined]
[3] format
@ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Printf\src\Printf.jl:720 [inlined]
[4] format(io::Base.TTY, f::Printf.Format{Base.CodeUnits{UInt8, String}, Tuple{Printf.Spec{Val{'G'}}}}, args::Float64)
@ Printf C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Printf\src\Printf.jl:803
[5] top-level scope
@ REPL[4]:1

It works as expected with f and e formats . This is with v1.6.2

@Seelengrab
Copy link
Contributor

Works for me on

julia> using Printf                            
                                               
julia> @printf("%G", NaN)                      
NaN                                            
julia> versioninfo()                           
Julia Version 1.7.0-DEV.1072                   
Commit 364660c5fd (2021-05-07 06:23 UTC)       
Platform Info:                                 
  OS: Linux (x86_64-linux-gnu)                 
  CPU: Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
  WORD_SIZE: 64                                
  LIBM: libopenlibm                            
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)       
Environment:                                   
  JULIA_PKG_SERVER =                           
  JULIA_NUM_THREADS = 4                        

can you try with one of the 1.7 betas?

@mwlidar
Copy link
Author

mwlidar commented Jul 19, 2021

julia> using Printf

julia> @printf("%f", Inf)
Inf

julia> @printf("%g", Inf)
ERROR: BoundsError: attempt to access 337-element Vector{UInt8} at index [0]
Stacktrace:
 [1] getindex
   @ .\array.jl:835 [inlined]
 [2] fmt
   @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\Printf\src\Printf.jl:429 [inlined]
 [3] format
   @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\Printf\src\Printf.jl:727 [inlined]
 [4] format(io::Base.TTY, f::Printf.Format{Base.CodeUnits{UInt8, String}, Tuple{Printf.Spec{Val{'g'}}}}, args::Float64)
   @ Printf C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.7\Printf\src\Printf.jl:811
 [5] top-level scope
   @ REPL[2]:1

julia> versioninfo()

Julia Version 1.7.0-beta3.0
Commit e76c9dad42 (2021-07-07 08:12 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.0 (ORCJIT, skylake)
Environment:
  JULIA_PKG_DEVDIR = H:\pc\julia

Same with 1.7 beta

@KristofferC
Copy link
Member

The next step is to find what commit fixed the issue so that it can be put into 1.7 and 1.6.

@jmkuhn
Copy link
Contributor

jmkuhn commented Jul 19, 2021

I still see this with the latest 1.8-DEV.

julia> @printf("%G", NaN)
ERROR: BoundsError: attempt to access 337-element Vector{UInt8} at index [0]
Stacktrace:
 [1] getindex
   @ ./array.jl:835 [inlined]
 [2] fmt
   @ ~/opt/julia/1.8-DEV/julia/usr/share/julia/stdlib/v1.8/Printf/src/Printf.jl:431 [inlined]
 [3] format
   @ ~/opt/julia/1.8-DEV/julia/usr/share/julia/stdlib/v1.8/Printf/src/Printf.jl:729 [inlined]
 [4] format(io::Base.TTY, f::Printf.Format{Base.CodeUnits{UInt8, String}, Tuple{Printf.Spec{Val{'G'}}}}, args::Float64)
   @ Printf ~/opt/julia/1.8-DEV/julia/usr/share/julia/stdlib/v1.8/Printf/src/Printf.jl:818
 [5] top-level scope
   @ REPL[6]:1

julia> versioninfo()
Julia Version 1.8.0-DEV.204
Commit 5a1680533b (2021-07-19 12:04 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.0 (ORCJIT, broadwell)

@barucden
Copy link
Contributor

Similarly to @jmkuhn, it is not working for me on the current master. I tried bisecting and ended up with c33877f:

julia> versioninfo()
Julia Version 1.7.0-DEV.1068
Commit c33877f417* (2021-05-04 21:04 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Xeon(R) Silver 4214R CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.0 (ORCJIT, cascadelake)

julia> using Printf; @printf("%G", NaN)
ERROR: BoundsError: attempt to access 337-element Vector{UInt8} at index [0]
Stacktrace:
 [1] getindex
   @ ./array.jl:833 [inlined]
 [2] fmt
   @ /local/temporary/julia/usr/share/julia/stdlib/v1.7/Printf/src/Printf.jl:428 [inlined]
 [3] format
   @ /local/temporary/julia/usr/share/julia/stdlib/v1.7/Printf/src/Printf.jl:720 [inlined]
 [4] format(io::Base.TTY, f::Printf.Format{Base.CodeUnits{UInt8, String}, Tuple{Printf.Spec{Val{'G'}}}}, args::Float64)
   @ Printf /local/temporary/julia/usr/share/julia/stdlib/v1.7/Printf/src/Printf.jl:803
 [5] top-level scope
   @ REPL[2]:1
bisect log
# bad: [5a1680533b461471f537f5f5d4ee3c2866b21e1f] Merge pull request #38405 from JuliaLang/vc/distributed_ts
# good: [5332d7d4e40ca2189e4ab597bf937f272f471bda] Fix 32-bit
git bisect start '5a1680533b461471f537f5f5d4ee3c2866b21e1f' '5332d7d4e40ca2189e4ab597bf937f272f471bda'
# bad: [e110029083da655f3cf340c5a3f26f89512dcfc2] Merge pull request #40928 from killercup/patch-1
git bisect bad e110029083da655f3cf340c5a3f26f89512dcfc2
# good: [c6a0748b9f5e6c75667a3f02e12950408a7c8761] Merge pull request #40540 from JuliaLang/jn/31979
git bisect good c6a0748b9f5e6c75667a3f02e12950408a7c8761
# good: [fd2061b77b7897d4336e3f1ac0822421a617c508] doc: fix typos in calling-c-and-fortran-code.md (#40692)
git bisect good fd2061b77b7897d4336e3f1ac0822421a617c508
# bad: [b054be5243ca4611d7bb3c7434b2342d103fbd56] faster `iseven(::BigInt)` (#40850)
git bisect bad b054be5243ca4611d7bb3c7434b2342d103fbd56
# bad: [6cebd28e66689828db5f98b5fa5a36b250779f18] `@something`: a short-circuiting `something` (#40729)
git bisect bad 6cebd28e66689828db5f98b5fa5a36b250779f18
# good: [27d39316da8b041b68111e7623c5a80f014c7404] Fix windows resource FILEVERSION (#40752)
git bisect good 27d39316da8b041b68111e7623c5a80f014c7404
# good: [79b8af2f51317fd554b44a19ee6bf694e6bf19e4] Merge pull request #40755 from bicycle1885/ryu-trimzeros
git bisect good 79b8af2f51317fd554b44a19ee6bf694e6bf19e4
# bad: [50fa83c71bbf47425378e3a72a413161c6fb4adc] Add logabsdet method for UmfpackLU (#40716)
git bisect bad 50fa83c71bbf47425378e3a72a413161c6fb4adc
# bad: [35d7571b15bbd0945f1e5391c043675748e1cb0b] Merge pull request #40689 from bicycle1885/printf-general
git bisect bad 35d7571b15bbd0945f1e5391c043675748e1cb0b
# bad: [c33877f417ce486ad864efbb2a5e4973c6a27e17] make Printf's general format C11 compliant
git bisect bad c33877f417ce486ad864efbb2a5e4973c6a27e17
# first bad commit: [c33877f417ce486ad864efbb2a5e4973c6a27e17] make Printf's general format C11 compliant

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

Successfully merging a pull request may close this issue.

5 participants