Your point about #3 does indeed look fishy. I'm not sure why they're calling
the destructor on their own anyways.

Try this:
// Retire this shake.
void *shake = m_ShakeList.Element( nShake );
m_ShakeList.FastRemove( nShake );
delete shake;
continue;

-----Original Message-----
From: hlcoders-boun...@list.valvesoftware.com
[mailto:hlcoders-boun...@list.valvesoftware.com] On Behalf Of Maarten De
Meyer
Sent: Thursday, March 31, 2011 11:38 AM
To: Discussion of Half-Life Programming
Subject: [hlcoders] CUtlVector crash ( screenshake )

Hi List!

So, we're finally out there in closed beta. One of the most annyoing issues
is a client side crash. The call stack doesn't say all that much, but still:
it always happens in the Purge command in the destructor of
CUtlVector:

template< typename T, class A >
inline CUtlVector<T, A>::~CUtlVector()
{
     Purge();
}

more precisely, in the CUtlVector< screenshake_t * > . [ There's only one of
those, in CViewEffects ].

Now, some questions:

1) any idea why this happens? [ had to ask :D ]
2) if no, any idea on how to debug?
3) Is the following normal? :

// Retire this shake.
delete m_ShakeList.Element( nShake );
m_ShakeList.FastRemove( nShake );
continue;

where:

template< typename T, class A >
void CUtlVector<T, A>::FastRemove( int elem ) {
     Assert( IsValidIndex(elem) );

     Destruct( &Element(elem) );
     if (m_Size > 0)
     {
         memcpy( &Element(elem), &Element(m_Size-1), sizeof(T) );
         --m_Size;
     }
}

and

template <class T>
inline void Destruct( T* pMemory )
{
     pMemory->~T();

#ifdef _DEBUG
     memset( pMemory, 0xDD, sizeof(T) ); #endif }

Concretely: how come it is allowed to first delete a pointer, and afterwards
still call the destructor on it? Is that not dangerous? [ Probably a c++
finesse I'm missing ] Shake works fine most of the time though ( I tried
with the console cheat command ), so it's not a reproducible crash yet - but
happens very often in online games.

Thanks in advance for any lights shed in the darkness!

-- Maarten

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders



_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to