mojo icon indicating copy to clipboard operation
mojo copied to clipboard

[BUG]: `Dict._find_index` doesn't check all index slots, can infinite loop

Open mzaks opened this issue 5 months ago • 8 comments

Bug description

While executing the code listed in reproduce section I experience a crash with following output:

Stack dump:
0.      Program arguments: /home/maxim/.modular/pkg/packages.modular.com_mojo/bin/mojo /home/maxim/dev/mojo_hash/test_hashmap.mojo
#0 0x000055abe8b7b937 (/home/maxim/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x622937)
#1 0x000055abe8b7950e (/home/maxim/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x62050e)
#2 0x000055abe8b7c00f (/home/maxim/.modular/pkg/packages.modular.com_mojo/bin/mojo+0x62300f)
#3 0x00007f9a2cc42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007f99b0003bdd 
Segmentation fault (core dumped)

Steps to reproduce

    let keys = String('Проснувшись однажды утром после беспокойного сна, Грегор Замза').split(" ")
    var d = Dict[StringKey, Int]()
    for i in range(len(keys)):
        d[keys[i]] = i

System information

Ubuntu 22.04.3 LTS
mojo 0.7.0 (af002202)
modular 0.4.1 (2d8afe15)

mzaks avatar Feb 04 '24 11:02 mzaks