No, both windows and linux. I suspected it was a valid construction. Still, 
that leaves me out of ideas :P

-----Original Message-----
From: Adam "amckern" McKern
Sent: vrijdag 1 april 2011 3:25
To: Discussion of Half-Life Programming
Subject: Re: [hlcoders] CUtlVector crash ( screenshake )

You might want to upgrade to memcpy_s if your windows server only (GCC has a 
dislike to microsoft non ISO code).
 

--------
Owner Nigredo Studios http://www.nigredostudios.com

--- On Fri, 1/4/11, Tony "omega" Sergi <omegal...@gmail.com> wrote:


From: Tony "omega" Sergi <omegal...@gmail.com>
Subject: Re: [hlcoders] CUtlVector crash ( screenshake )
To: "Discussion of Half-Life Programming" <hlcoders@list.valvesoftware.com>
Cc: "Tony Paloma" <drunkenf...@hotmail.com>
Received: Friday, 1 April, 2011, 12:10 PM


It's destructing the container the pointer to your object is stored in, not the 
object itself.
PurgeAndDelete on the other hand will destroy the object itself as well.





On Fri, Apr 1, 2011 at 4:02 AM, Tony Paloma <drunkenf...@hotmail.com> wrote:

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




-- 
-Tony


-----Inline Attachment Follows-----


_______________________________________________
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