Euphoria
Ticket #862:
bug in cmdline.e handle_opt()
-
Reported by
coconut
Apr 03, 2013
call map:put with APPEND but crash push() because value associated with the key is an atom.
bugreport result:
Version
----------------------------
4.1.0 development (5807:13235c1f4751, 2012-10-30 15:18:38)
Operating System
----------------------------
Platform: Linux, Build: efikamx, 2.6.31.14.27-efikamx:0
Include Directories
----------------------------
1: /usr/share/euphoria/bin
2: /usr/share/euphoria/include
PATH
----------------------------
/home/Jacques/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/share/euphoria/bin
ex.err
/usr/share/euphoria/include/std/map.e:645 in procedure put()
first argument of append must be a sequence
the_map_p = 10
key = {105'i'}
val = {47'/',117'u',115's',114'r',47'/',115's',104'h',97'a',114'r',101'e',
47'/',101'e',117'u',112'p',104'h',111'o',114'r',105'i',97'a',47'/',105'i',
110'n',99'c',108'l',117'u',100'd',101'e'}
op = 6
deprecated = 0
hashval = 105200131
the_map_seq = {1,0,5}
slots = {
{-2,0,0},
{-2,0,0},
{-2,0,0},
{-2,0,0},
{-2,0,0},
{-2,0,0},
{-2,0,0},
{-2,0,0},
{-2,0,0},
{-2,0,0},
{-2,0,0},
{-2,0,0},
{-2,0,0},
{-2,0,0},
{-2,0,0},
{
901613966,
{110'n',111'o',98'b',117'u',105'i',108'l',100'd'},
1
}
}
index = 16
old_hash = 901613966
msg (from inlined routine 'crash' at 264) = <no value>
msg (from inlined routine 'crash' at 313) = <no value>
msg (from inlined routine 'crash' at 482) = <no value>
... called from /usr/share/euphoria/include/std/cmdline.e:1164 in function handle_opt()
Details
1. Comment by mattlewis
Apr 04, 2013
Here's what I tried:
include std/map.e
map m1 = map:new()
map:put( m1, "nobuild", 1 )
map:put( m1, "i", "/usr/share/euphoria/include", map:APPEND )
This worked for me. Also, in map.e, I find the APPEND code for map:put starting at line 631:
case APPEND then
if old_hash < 0 then
slots[index] = { hashval, key, {val} }
else
slots[index] = { hashval, key, append( slots[index][SLOT_VALUE], val ) }
end if
Somehow, it's trying to append something for key "i" to the slot for key "nobuild". Can you please confirm which version of map.e you're using?
2. Comment by mattlewis
Apr 04, 2013
This does present an interesting question. Suppose we had the code:
m1 = map:new()
map:put( m1, "a", 1 )
map:put( m1, "a", "foo", map:APPEND )
For this, I get the same error (though it reports line 635). Should we promote an atom to a sequence and append? Or is it better to crash, because this is probably a bug in the user's code?
3. Comment by coconut
Apr 04, 2013
I cloned the mercurial repo and I'm building from lastest commit. As reported the problem in this case is in cmdline.e or upper in call tree not in map.e
4. Comment by mattlewis
Apr 04, 2013
I don't understand the last comment in relation to the original ticket information, which seems to indicate a map lookup problem.
5. Comment by jimcbrown
Apr 04, 2013
Why the heck is cmdline.e putting an atom into a map? I'd have thought that all command line options would be strings.
6. Comment by mattlewis
Apr 04, 2013
It's not the option (i.e., key) itself, but the value, which is a 1. The key is "nobuild". It's an option without a parameter, I think, so when you call map:get(), you get back 1 when the option is present.
Something is going wrong inside of lookup() where it's not returning the right thing. Due to the nature of hashes and hash tables, this sort of thing is really difficult to recreate if you don't have the source data, which we don't (ex.err output is truncated for really long sequences).
I really suspect this is some sort of ARM floating point to integer conversion problem. It works very differently from x86.
7. Comment by SDPringle
Jun 26, 2014
When using map:put with APPEND one has to initialize the image with {}. This happens in cmdline.e. This is a broken ARM problem.
8. Comment by SDPringle
Sep 14, 2014
I cannot reproduce this. I hereby abandon this ticket to someone who can. If they cannot we can 'mark it fixed please confirm' until someone can.