Program Error in hash.cpp - access violation Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
glenc
In need of some credit
In need of some credit
Posts: 3
Joined: Wed Feb 07, 2007 7:22 pm

Program Error in hash.cpp - access violation

Post by glenc » Wed Feb 07, 2007 7:51 pm

Getting an access violation in the statement

Code: Select all

    size_t slot = (size_t)abs((int)(key % (long)m_hashSize));
because m_hashSize is undefined. This is in the function

Code: Select all

wxNodeBase *wxHashTableBase::GetNode(long key, long value) const
{
    size_t slot = (size_t)abs((int)(key % (long)m_hashSize));

    wxNodeBase *node;
    if ( m_hashTable[slot] )
    {
        node = m_hashTable[slot]->Find(wxListKey(value));
    }
    else
    {
        node = (wxNodeBase *)NULL;
    }

    return node;
}
contained in hash.cpp.
In tracing the code, it arrives here when executing the macro IMPLEMENT_APP(appName). The variable m_hashSize is initialized in the constructor for wxHashTableBase which doesn't appear to be executed.
The program compiles and links error free.
My environment is
Windows XP
wxWidgets 2.6.3
Borland C++Builder 6
I would greatly appreciate any suggestions.

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: Program Error in hash.cpp - access violation

Post by Auria » Thu Feb 08, 2007 1:04 am

glenc wrote: wxWidgets 2.6.3
Can you test it in 2.8? If you file a bug report for and old version, it may not be considered as much as if it is confirmed to happen in the latest.

Also, can you post the code that makes it crash? (or does it always crash)

glenc
In need of some credit
In need of some credit
Posts: 3
Joined: Wed Feb 07, 2007 7:22 pm

Post by glenc » Thu Feb 08, 2007 1:39 am

Yes, I can try it in 2.8, but it will take me a couple of days. And yes, it always crashes.
In the meantime, I noticed that the code in app.h was generated because of

Code: Select all

#define WXWIN_COMPATIBILITY_2_4 1
in setup.h. I changed this to a value of 0 and rebuilt wxWidgets. Now the program aborts at

Code: Select all

    wxASSERT( m_keyType == wxKEY_INTEGER );
in the function

Code: Select all

void* wxHashTableBase::DoGet( long key, long hash ) const
{
    wxASSERT( m_keyType == wxKEY_INTEGER );

    size_t bucket = size_t(hash) % m_size;

    if( m_table[bucket] == NULL )
        return NULL;

    Node *first = m_table[bucket]->GetNext(),
         *curr = first;

    do
    {
        if( curr->m_key.integer == key )
            return curr->m_value;

        curr = curr->GetNext();
    }
    while( curr != first );

    return NULL;
}
because m_keytype is undefined.
Will try it under 2.8 and post the results.

glenc
In need of some credit
In need of some credit
Posts: 3
Joined: Wed Feb 07, 2007 7:22 pm

Post by glenc » Mon Feb 12, 2007 3:58 pm

Can you test it in 2.8?
Have now done so, and the problem is solved. Thanks.

Post Reply