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 the itruncalypse #8549

Merged
merged 9 commits into from
Oct 3, 2014
Merged

Fix the itruncalypse #8549

merged 9 commits into from
Oct 3, 2014

Conversation

staticfloat
Copy link
Sponsor Member

I have to give credit to @nolta for a name that has kept me smiling all afternoon.

This tries to excise all mention in Base of uint(LITERAL) where LITERAL is 64 bits wide. This builds on my 32-bit VM, but I'd like a human eye to go over this and make sure I'm not doing anything horrendously stupid here.

@staticfloat
Copy link
Sponsor Member Author

@JeffBezanson What do you want to do about things such as these tests? We have some kind of interesting behavior here:

$ ./julia 
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.0-dev+906 (2014-10-01 23:27 UTC)
 _/ |\__'_|_|_|\__'_|  |  sf/itruncalypse/1f5c846 (fork: 8 commits, 0 days)
|__/                   |  i686-linux-gnu

julia> -170141183460469231731687303715884105729
-170141183460469231731687303715884105729

julia> -9223372036854775809
ERROR: InexactError()

@tkelman
Copy link
Contributor

tkelman commented Oct 2, 2014

This bootstraps on Win32, nice work, but fails the numbers tests as you saw.

        From worker 4:       * numbers
exception on 4: ERROR: InexactError()
while loading numbers.jl, in expression starting on line 69
ERROR: InexactError()
while loading numbers.jl, in expression starting on line 69

@JeffBezanson
Copy link
Sponsor Member

That's strange. All those tests should still pass.
Many thanks for doing this!

@staticfloat
Copy link
Sponsor Member Author

The InexactError from entering the literal -9223372036854775809 is coming from *(u::Int128, v::Int128), but I don't really know what to do here.

The crux of the problem is that widemul(int64(-1), int64(1)) throws an InexactError:

julia> widemul(int64(-1), int64(1))
rec_backtrace at /home/vagrant/buildbot/slave/build_ubuntu14_04-x86/build/usr/bin/../lib/libjulia.so (unknown line)
unknown function (ip: -1231114184)
jl_throw at /home/vagrant/buildbot/slave/build_ubuntu14_04-x86/build/usr/bin/../lib/libjulia.so (unknown line)
unknown function (ip: -1231113459)
widemul at int.jl:394
jlcall_widemul;39913 at  (unknown line)
jl_apply_generic at /home/vagrant/buildbot/slave/build_ubuntu14_04-x86/build/usr/bin/../lib/libjulia.so (unknown line)
unknown function (ip: -1231144368)
unknown function (ip: -1231148216)
unknown function (ip: -1231078163)
jl_toplevel_eval_in at /home/vagrant/buildbot/slave/build_ubuntu14_04-x86/build/usr/bin/../lib/libjulia.so (unknown line)
jl_f_top_eval at /home/vagrant/buildbot/slave/build_ubuntu14_04-x86/build/usr/bin/../lib/libjulia.so (unknown line)
eval_user_input at REPL.jl:54
jlcall_eval_user_input;39890 at  (unknown line)
jl_apply_generic at /home/vagrant/buildbot/slave/build_ubuntu14_04-x86/build/usr/bin/../lib/libjulia.so (unknown line)
anonymous at task.jl:96
jl_trampoline at /home/vagrant/buildbot/slave/build_ubuntu14_04-x86/build/usr/bin/../lib/libjulia.so (unknown line)
unknown function (ip: -1231115741)
julia_trampoline at /home/vagrant/buildbot/slave/build_ubuntu14_04-x86/build/usr/bin/../lib/libjulia.so (unknown line)
unknown function (ip: 134516370)
__libc_start_main at /lib/i386-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 134516419)
ERROR: InexactError()
 in widemul at int.jl:394

This is due to the multiplication of u1 and v0 here, which is mixing signed and unsigned integers in multiplication. Any ideas on how this might be fixed? Also, I wonder why these errors are appearing on 32-bit but not on 64-bit builds?

@JeffBezanson
Copy link
Sponsor Member

Reinterpreting u1 as unsigned will probably work since that's basically
what we did before.

@staticfloat
Copy link
Sponsor Member Author

Unfortunately I don't really have the time to figure out what to do with these functions. There is a lot of mixing uint and int in this file, basically every time you have uX * vY where X != Y. I realize it's hard to debug this without a 32-bit machine, so if you want access to my 32-bit VM I can send you an email, but I don't think I'll be able to solve this myself for a couple days.

for x in s
h $= hash(x)
end
return h
end

const hashis_seed = Uint === Uint64 ? 0x88989f1fc7dea67d : 0xc7dea67d
function hash(s::IntSet, h::Uint)
h += uint(0x88989f1fc7dea67d)
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you forgot to use hashis_seed here.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@JeffBezanson
Copy link
Sponsor Member

Not a big deal, but all the uint() calls on the constants can also be removed now.

@staticfloat
Copy link
Sponsor Member Author

I like saving harddrive space by cutting down on character counts just as much as anyone.

JeffBezanson added a commit that referenced this pull request Oct 3, 2014
@JeffBezanson JeffBezanson merged commit a74ac4e into master Oct 3, 2014
@JeffBezanson JeffBezanson deleted the sf/itruncalypse branch October 25, 2014 17:23
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 this pull request may close these issues.

3 participants