Access Violation in hkArray,inL

Access Violation in hkArray,inL

Ok, i got the linker errors straightend out thanks to Benny53, now i'm getting access violations in hkArray.inL

it points to this line:

return (m_capacityAndFlags & static_cast<int>(CAPACITY_MASK));

and here is my Initialize function:

int InitializeHavok()


hkPoolMemory* MemoryManager = new hkPoolMemory();

hkThreadMemory* Threads = new hkThreadMemory(MemoryManager, 16);

hkBaseSystem::init(MemoryManager, Threads, MessageHandler);





int stackSize = 0x1000000;

stackBuffer = hkAllocate<char>( stackSize, HK_MEMORY_CLASS_BASE);

hkThreadMemory::getInstance().setStackArea( stackBuffer, stackSize);




hkpWorldCinfo worldInfo;

worldInfo.m_simulationType = hkpWorldCinfo::SIMULATION_TYPE_MULTITHREADED;

PhysicalWorld = new hkpWorld(worldInfo);



hkMemory::getInstance().preAllocateRuntimeBlock(512000, HK_MEMORY_CLASS_BASE);

hkMemory::getInstance().preAllocateRuntimeBlock(256000, HK_MEMORY_CLASS_BASE);

hkMemory::getInstance().preAllocateRuntimeBlock(128000, HK_MEMORY_CLASS_BASE);

hkMemory::getInstance().preAllocateRuntimeBlock(64000, HK_MEMORY_CLASS_BASE);

hkMemory::getInstance().preAllocateRuntimeBlock(32000, HK_MEMORY_CLASS_BASE);

hkMemory::getInstance().preAllocateRuntimeBlock(16000, HK_MEMORY_CLASS_BASE);

hkMemory::getInstance().preAllocateRuntimeBlock(16000, HK_MEMORY_CLASS_BASE);




hkpAgentRegisterUtil::registerAllAgents( PhysicalWorld->getCollisionDispatcher());


hkpMultithreadingUtilCinfo info;

info.m_world = PhysicalWorld;

info.m_numThreads = NUM_THREADS;

info.m_enableTimers = true;

hkpMultithreadingUtil* multithreadingutil = new hkpMultithreadingUtil(info);

//hkpPhysicsContext* context = new hkpPhysicsContext();



//hkVisualDebugger* vdb = SetupVisualDebugger(context);





return 1;


if you guys have any idea on what's going on, please let me know. i've been going crazy trying to set Havok up while other people already got a cube falling or something (Benny53!!)

7 帖子 / 0 全新

Can you provide more information.

What does the callstack say? What part of the your code is invoking this error?

Again, have you tried running the sample stand-alone demo? Does it work?

The stand alone sample works fine. it's my code that's messed up for some reason. and where would i find the callstack? i don't know too much about MSVC++ but do you mean the debug window that says all that stuff? like the access violations? cause i tried to add alot of break points and says everything i added a break point to is cauing the access violation. So, i don't know....what it could be. Maybe i didn't code it good?

Ok, well, i found the stack frame thing and it says that there's a few functions that are in the resd it seems. i'm uploading an image of what those are.

I'm not sure if you'll be able to see them, but let me know and i'll make them bigger.

Hi there,

The code that you have posted will not compile. The variable 'context' is never declared. My guess is that in your own code context is uninitialsed, and so the call to context->m_monitorStreamBegins.setSize(NUM_THREADS) fails.

Best Regards,


Ok, i put visual debugger back, but now i get 6 linker errors :-(

1>Physics.obj : error LNK2019: unresolved external symbol "class hkVisualDebugger * __cdecl SetupVisualDebugger(class hkpPhysicsContext *)" (?SetupVisualDebugger@@YAPAVhkVisualDebugger@@PAVhkpPhysicsContext@@@Z) referenced in function "int __cdecl InitializeHavok(void)" (?InitializeHavok@@YAHXZ)

1>hkSerialize.lib(hkBuiltinTypeRegistry.obj) : error LNK2001: unresolved external symbol "public: static class hkClass const * const * const hkBuiltinTypeRegistry::StaticLinkedClasses" (?StaticLinkedClasses@hkBuiltinTypeRegistry@@2QBQBVhkClass@@B)

1>hkSerialize.lib(hkBuiltinTypeRegistry.obj) : error LNK2001: unresolved external symbol "public: static class hkTypeInfo const * const * const hkBuiltinTypeRegistry::StaticLinkedTypeInfos" (?StaticLinkedTypeInfos@hkBuiltinTypeRegistry@@2QBQBVhkTypeInfo@@B)

1>hkSerialize.lib(hkVersionRegistry.obj) : error LNK2001: unresolved external symbol "public: static struct hkVersionRegistry::Updater const * * hkVersionRegistry::StaticLinkedUpdaters" (?StaticLinkedUpdaters@hkVersionRegistry@@2PAPBUUpdater@1@A)

1>hkSerialize.lib(hkVersionRegistry.obj) : error LNK2001: unresolved external symbol "public: static class hkStaticClassNameRegistry const * * hkVersionRegistry::StaticLinkedClassRegistries" (?StaticLinkedClassRegistries@hkVersionRegistry@@2PAPBVhkStaticClassNameRegistry@@A)

1>.Debug/Framework.exe : fatal error LNK1120: 5 unresolved externals

so i don't know what to do. if i remove that, it'll work but then i'll get an access violation, so what lib do i need to add to make it work? as i've added every lib in Havok.

Hi there,

You need to link in some serialization data for the VDB. See this post from johnb003: