Terrible, bad bug in 0.99.3

From: Martin Sevior (msevior@mccubbin.ph.unimelb.edu.au)
Date: Sun Mar 17 2002 - 04:04:11 GMT

  • Next message: Martin Sevior: "commit:Re: Terrible, bad bug in 0.99.3"

    Do this:

    Open the release notes in abiword. Then open the 0.99.3 change log in
    another abiword view. Then remove one toolbar from the current view.

    AbiWord hangs while it spawns an infinite number of spellchecker
    instances.

    I traced the bug to spell_manager.cpp:

    In method: requestDictionary(const char * szLang)

    There is the code:

    // first look up the entry in the hashtable
            if (m_map.contains (szLang, 0))
            {
                    return (SpellCheckerClass *)m_map.pick (szLang);
            }

            // not found, so insert it
            checker = new SpellCheckerClass ();
            
            if (checker->requestDictionary (szLang))
        {
                    m_map.insert (szLang, (void *)checker);
                    m_lastDict = checker;
                    m_nLoadedDicts++;
                    return checker;
        }

    So the code looks for the dictionary in the hash map otherwise it makes a
    new instances and saves it to be found the next time through. OK This
    should all work right?

    NO!

    the contains() method of hash map is buggy. It sometimes works and
    sometimes doesn't. I disabled it once before in xap_Dictionary.cpp. Here
    is the code trail....

    //
    // This original code does not work. I believe it is a bug in the hash table.
    //
    #if 0
            char * key = (char*) calloc(len+1, sizeof(char));
            if (!key)
            {
                    UT_DEBUGMSG(("mem failure looking up word in
    dictionary\n"));
                    FREEP(key);
                    return false;
            }
            UT_uint32 i =0;
            for (i = 0; i < len; i++)
            {
                    key[i] = (char) static_cast<unsigned char>( pWord[i]);
                    xxx_UT_DEBUGMSG(("isword key[%d] = %c %d
    \n",i,key[i],key[i]));
                    if(key[i] == 0)
                            break;
            }
            key[i] = 0;
            char * key2 = UT_strdup(key);
            bool contains = m_hashWords.contains (key2, NULL);
            FREEP(key);
            FREEP(key2);
            return contains;
    #else

    contains( , ) fails here too.

    I've done a grep through the source and found the contains method is used
    elsewhere in AbiWord.

    So please, whoever is repsonible the hashtable, fix the
    contains(..) method!!!

    I'll work around the bug in spellcheck using vectors again. But please fix
    the hash map code!!!

    Thank you

    Martin



    This archive was generated by hypermail 2.1.4 : Sat Mar 16 2002 - 23:10:58 GMT