-
Notifications
You must be signed in to change notification settings - Fork 22
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
BoundsError in transpose(::Vector{Dec128})
#38
Comments
A reduced case that still exhibits the problem is: julia> collect(v for i in 1:1, v in x)
ERROR: BoundsError: attempt to access 5-element Array{DecFP.Dec128,1} at index [6]
in prod_next at ./iterator.jl:527 [inlined]
in next at ./iterator.jl:538 [inlined]
in next at ./generator.jl:25 [inlined]
in collect_to!(::Array{DecFP.Dec128,2}, ::Base.Generator{Base.Prod2{UnitRange{Int64},Array{DecFP.Dec128,1}},##11#12}, ::Int64, ::Tuple{Int64,Int64,Nullable{DecFP.Dec128},Bool}) at ./array.jl:340
in collect(::Base.Generator{Base.Prod2{UnitRange{Int64},Array{DecFP.Dec128,1}},##11#12}) at ./array.jl:308 Swapping the ranges causes a segfault: julia> collect(v for v in x, i in 1:1)
signal (11): Segmentation fault
while loading no file, in expression starting on line 0
next at ./generator.jl:25 [inlined]
collect_to! at ./array.jl:340
collect at ./array.jl:308
unknown function (ip: 0x7fe136c070e2)
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:210 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1950
do_call at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:66
eval at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:190
eval_body at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:465
jl_interpret_call at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:573
jl_toplevel_eval_flex at /home/centos/buildbot/slave/package_tarball64/build/src/toplevel.c:572 [inlined]
jl_toplevel_eval at /home/centos/buildbot/slave/package_tarball64/build/src/toplevel.c:580
jl_toplevel_eval_in_warn at /home/centos/buildbot/slave/package_tarball64/build/src/builtins.c:590
eval at ./boot.jl:234
unknown function (ip: 0x7fe35b0efc9f)
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:210 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1950
eval_user_input at ./REPL.jl:64
unknown function (ip: 0x7fe136bcad46)
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:210 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1950
macro expansion at ./REPL.jl:95 [inlined]
#3 at ./event.jl:68
unknown function (ip: 0x7fe136bc7ecf)
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:210 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1950
jl_apply at /home/centos/buildbot/slave/package_tarball64/build/src/julia.h:1392 [inlined]
start_task at /home/centos/buildbot/slave/package_tarball64/build/src/task.c:254
unknown function (ip: 0xffffffffffffffff)
Allocations: 4365820 (Pool: 4364674; Big: 1146); GC: 5 Perhaps this is related to JuliaLang/julia#21216 ? Edit: I can also reproduce it on macOS, so perhaps it's not related to 21216. |
With Julia 0.6, I get: julia> transpose(zeros(Dec128, 5))
1×5 RowVector{DecFP.Dec128,Array{DecFP.Dec128,1}}:
+0E+0 +0E+0 +0E+0 +0E+0 +0E+0 |
Perhaps my v0.6 is too old. I'll update again. |
With the latest 0.6 I get: julia> collect(v for i in 1:1, v in zeros(Dec64, 1))
1×1 Array{DecFP.Dec64,2}:
+0E+0
julia> collect(v for i in 1:1, v in zeros(Dec128, 1))
1×1 Array{DecFP.Dec128,2}:
+4639814192E-6176 which is clearly wrong (it seems to be accessing invalid memory). But I'm guessing it is related to JuliaLang/julia#21216? |
Yeah, I can confirm that transpose is working on the latest v0.6, but I'm still getting some segfaults: julia> x = zeros(Dec128, 5)
5-element Array{DecFP.Dec128,1}:
+0E+0
+0E+0
+0E+0
+0E+0
+0E+0
julia> transpose(x)
1×5 RowVector{DecFP.Dec128,Array{DecFP.Dec128,1}}:
+0E+0 +0E+0 +0E+0 +0E+0 +0E+0
julia> collect(v for i in 1:1, v in x)
[1] 31025 segmentation fault julia-0.6 This is on macOS, so maybe JuliaLang/julia#21216 is not actually restricted to linux? |
Yup seems like a Julia bug. abstract type DecimalFloatingPoint <: AbstractFloat end
primitive type Dec128 <: DecimalFloatingPoint 128 end
collect(v for i in 1:1, v in [reinterpret(Dec128, UInt128(0))]) gives
in Julia 0.6, and abstract DecimalFloatingPoint <: AbstractFloat
bitstype 128 Dec128 <: DecimalFloatingPoint
collect(v for i in 1:1, v in [reinterpret(Dec128, UInt128(0))]) gives
in Julia 0.5. |
Closing this issue as a duplicate of #37. |
Ok, thanks @stevengj ! |
By the way, in case you're interested, the reason this came up is that I've ported the original Lawson & Hanson non-negative least squares code from Fortran to Julia, so now I'm having some fun trying out NNLS problems with different levels of floating-point precision: https://github.com/rdeits/nnls.jl |
Attempting to transpose a vector of
Dec128
fails with a BoundsError on Julia v0.5 and v0.6, running in Ubuntu 14.04 and macOS. I can reproduce this both on the last tagged release of DecFP and on master.This occurs regardless of the length of the vector:
reshape()
works fine, andtranspose()
works fine for vectors ofDec64
andDec32
. Transpose also works for 2-dimensional arrays of Dec128.size()
andlength()
give the right answers:Any ideas?
The text was updated successfully, but these errors were encountered: