HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

H2I bug

04-10-2008, 03:17 PM#1
Strilanc
I was modifying HAIL so it could accept two handles and I stumbled on this. It looks like H2I is bugged the same way I2Code and I2R are bugged: the return value isn't always safe unless you put a helper in between.

Collapse JASS:
function H2I takes handle h returns integer
    return h
    return 0
endfunction
function crash takes nothing returns nothing
    local integer i = H2I(Location(0,0))
    set i = i + H2I(Location(0,0)) //crash
endfunction
function nocrash takes nothing returns nothing
    local integer i = H2I(Location(0,0))
    local integer j = H2I(Location(0,0))
    set i = i + j
endfunction
04-10-2008, 04:08 PM#2
Vexorian
I don't think this is the same problem as I2Code.

For the sake of the fact that the I2Code issue is much easier to find.

It could be related to addition , but this is odd, too bad I am away of something that can test this stuff.
04-10-2008, 04:52 PM#3
Strilanc
Ok, this just became a LOT more interesting. Apparently the order of the addition matters.

Collapse JASS:
function H2I takes handle h returns integer
    return h
    return 0
endfunction
function crash takes nothing returns nothing
    local integer i = H2I(Location(0,0))
    set i = i + H2I(Location(0,0)) //crash
endfunction
function nocrash takes nothing returns nothing
    local integer i = H2I(Location(0,0))
    set i = H2I(Location(0,0)) + i //no crash
endfunction

To top it off: subtraction, multiplication and division do not crash. I think I might have just found why my op counter wasn't working: addition has a bug (almost impossible to hit by accident).

*edit* nope, subtraction crashes sometimes, just like addition, when going over the op limit.
04-10-2008, 09:44 PM#4
Toadcop
lol... maybe your war3 uses warmachine ? =) aka grimoire injects it.
well a crash is really odd TT. hmm it's interesting btw i will test it now.

btw... maybe it's grimore O_o (war3err) !?

ahhh lol indeed xD a "written" error lolzor aka serious one... rofl n/c

but well in practise how i remember i never get errors like that weird...
04-10-2008, 10:10 PM#5
Strilanc
Quote:
Originally Posted by Toadcop
lol... maybe your war3 uses warmachine ? =) aka grimoire injects it.
well a crash is really odd TT. hmm it's interesting btw i will test it now.

btw... maybe it's grimore O_o (war3err) !?

ahhh lol indeed xD a "written" error lolzor aka serious one... rofl n/c

but well in practise how i remember i never get errors like that weird...

04-10-2008, 10:35 PM#6
PurgeandFire111
Quote:
Originally Posted by Toadcop
lol... maybe your war3 uses warmachine ? =) aka grimoire injects it.
well a crash is really odd TT. hmm it's interesting btw i will test it now.

btw... maybe it's grimore O_o (war3err) !?

ahhh lol indeed xD a "written" error lolzor aka serious one... rofl n/c

but well in practise how i remember i never get errors like that weird...

It is a tough guess, but I think he means you should try to turn of war3err and see if that is the cause.

English isn't TC's native language.
04-10-2008, 10:37 PM#7
Vexorian
Quote:
Ok, this just became a LOT more interesting. Apparently the order of the addition matters.
Stack stuff.

The moral would be: don't use + among handle ids.
04-10-2008, 11:01 PM#8
Toadcop
Quote:
The moral would be: don't use + among handle ids.
+1 ^^
04-11-2008, 06:18 AM#9
PandaMine
Man if only stacking in JASS would be the same as C/C++

If only ....
04-11-2008, 01:01 PM#10
Toadcop
Quote:
Man if only stacking in JASS would be the same as C/C++
and how it's in C++ ? anyway jass runs on virtual machine. ("emulation") imho it's done for compability and no need to compile the stuff :P
04-11-2008, 01:31 PM#11
PandaMine
In C++ it is very elegant, you modify stacks by looking at the memory using pointers and such
04-11-2008, 11:45 PM#12
TheDamien
According to Blizzard the SC2 scripting language will be based off C, maybe that means there will be the possibility of low level memory access and management?
04-11-2008, 11:58 PM#13
Toadcop
Jass is based off C... lol never to allow stupid map makers to edit memory lol viruses <3 etc.
// dream...
04-12-2008, 12:02 AM#14
Vexorian
Quote:
According to Blizzard the SC2 scripting language will be based off C

Yeah well.

There's no way to guess what that means.
- C-like syntax?
- Powerful like C?
- Like C as in "python is like C" ?
- Like C as in "Jass is like C" ?
04-12-2008, 12:07 AM#15
Toadcop
Quote:
- Like C as in "Jass is like C" ?
or use the publick joker...
according to Blizz screenshots SC2 is WoW in space...