I don't have much of a callstack because I'm just calling hkMonitorStream::getInstance().resize( 2 * 1024 * 1024 ) from my code. This is on a background thread, not the main thread.
Looking at the assembly, I see that hkMonitorStream__m_instance::m_slotID is 43. The call to TlsGetValue returns 0 and the program crashes inside hkMonitorStream::resize (access violation reading 0x00000000).
If I try this earlier on the main thread, the slot ID is still 43 but TlsGetValue resolves to a valid hkMonitorStream pointer (obviously, each thread has its own pointer). I have no actual need to resize the monitor stream on the background thread, but further access to the monitor stream on this thread also crashes (for example, simply adding a rigid body to the world).
Havok is basically working right now in the multithreaded way we're using it. I've just uncovered this problem as I'm trying to hook up the visual debugger.
Can anyone tell me how a hkMonitorStream is allocated and assigned to the thread-local storage slot? That info would help me track down what we're doing wrong.