septag / rizz

Small C game development framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example 08-draw3d locks up during startup

jonstvns opened this issue · comments

Running the 08-draw3d example on Windows with VS2019 results in an unresponsive white screen. It appears that the asset system tries to start a job to read and load the a 3d asset, but it gets stuck in a spin waiting for a lock to be released.

rizz.exe!sx_anderson_lock_enter(sx_anderson_lock_t * lock) Line 793
	at C:\Work\rizz\src\sx\src\threads.c(793)
rizz.exe!sx_job_dispatch(sx_job_context * ctx, int count, void(*)(int, int, int, void *) callback, void * user, sx_job_priority priority, unsigned int tags) Line 320
	at C:\Work\rizz\src\sx\src\jobs.c(320)
rizz.exe!rizz__job_dispatch(int count, void(*)(int, int, int, void *) callback, void * user, sx_job_priority priority, unsigned int tags) Line 1757
	at C:\Work\rizz\src\rizz\core.c(1757)
rizz.exe!rizz__asset_on_read(const char * path, sx_mem_block * mem, void * user) Line 328
	at C:\Work\rizz\src\rizz\asset.c(328)
rizz.exe!rizz__vfs_async_update() Line 397
	at C:\Work\rizz\src\rizz\vfs.c(397)
rizz.exe!rizz__core_frame() Line 1582
	at C:\Work\rizz\src\rizz\core.c(1582)
rizz.exe!rizz__app_frame() Line 476
	at C:\Work\rizz\src\rizz\app.c(476)
rizz.exe!_sapp_call_frame() Line 1146
	at C:\Work\rizz\3rdparty\sokol\sokol_app.h(1146)
rizz.exe!_sapp_frame() Line 1266
	at C:\Work\rizz\3rdparty\sokol\sokol_app.h(1266)
rizz.exe!_sapp_run(const sapp_desc * desc) Line 5007
	at C:\Work\rizz\3rdparty\sokol\sokol_app.h(5007)
rizz.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 5086
	at C:\Work\rizz\3rdparty\sokol\sokol_app.h(5086)

If you modify the k_models array in draw3d.c to only contain 1 asset, then the main thread is unblocked, but the asset still doesn't load since the thread trying to load the asset is also stuck in a spin.

Commenting out the spin completely to ignore the lock makes everything work and load correctly, but ofc that's bad and not a real workaround.

System Info:

  • Windows 10 Pro
  • Version 10.0.19042 Build 19042
  • Visual Studio 2019 16.11.3
  • Platform toolset v142

can you tell me the cpu model and core count?

Intel i7-9750H @ 2.60GHz, 6 Cores, 12 Logical Processors

damn. the thing is that I'm trying out a new anderson spinlock implementation. works ok with the cpus I've tested, but oddly, locks on yours. Since, I can't debug it on any of my machines. I'll try to come up with something new and keep you posted

ok, could you test again with the latest changes ?

I have changed the spinlock implementation to a simpler one. Also overhauled the entire atomics.

Latest is working now on my machine. A clean build of 08-draw3d functions as expected.

Sorry for the delayed response, was out of the country.

not a problem, thank you