bmap_process crashes

Posted By: Superku

bmap_process crashes - 12/18/18 19:04

Hello!
I've been using bmap_process for quite some time now as a means of an animated loading screen/ level transition.
Most of the time it's working fine. However, every now and then it's crashing sadly (sometimes weeks apart).

I'm calling bmap_process in the on_level event (and for another bitmap + material in some other menu code) where it may crash although having worked fine before during the same game session. Pointers are all valid it seems.
The crash only seems to happen during level loading.

Do you see anything in the source code where that could be an issue? Or do you have any other idea what do do?

Thanks.
Posted By: jcl

Re: bmap_process crashes - 12/19/18 12:10

Not at first glance. It doesn't crash here. Are you sure that it is bmap_process that crashes, not something else?
Posted By: Superku

Re: bmap_process crashes - 12/19/18 12:43

Thanks for looking into it. I'm rather certain that the crash happens in bmap_process though. Here's my on_level event:

Code:
void level_load_progress(var percent)
{
	cprintf1("nLLPM(%d)",(int)percent);
	if(percent < 5) pp_renderchain_debug(0);
	int hresult = material_update_float(pp_levelload_mat, "loadpercent", percent);
	cprintf1(" MUF(%d) ",hresult);

	cprintf4("m(ll %p, rc %p, mat %p, effect %p)",levelload_bmap,renderchain_bmap,pp_levelload_mat, pp_levelload_mat->d3deffect);
	bmap_process(levelload_bmap,renderchain_bmap,pp_levelload_mat);
	cprintf0("b");

	draw_quad(levelload_bmap,nullvector,NULL,NULL,NULL,NULL,100,0);
	cprintf0("d");
	material_update_float(emotesTransition_mat, "loadpercent", percent);
	cprintf0("f");
	draw_obj(entEmotesTransition);
	cprintf0("e");
	level_load_percent = percent;
}



Click to reveal..
Code:
// made by Rackscha, adapted by Superku

//#define DEVTRUE

#ifndef Console_h
	#define Console_h
	#include<windows.h>;

	long WINAPI WriteConsole(int Handle, char* Buffer, int CharsToWrite, int* CharsWritten, int reserved);
	long WINAPI CreateConsoleScreenBuffer(long dwDesiredAccess, long dwShareMode, long *lpSecurityAttributes, long dwFlags, long lpScreenBufferData);
	long WINAPI SetConsoleActiveScreenBuffer(long hConsoleOutput);
	long GConsoleBuffer;
	int consoleInitialized = 0;
	#ifdef DEVTRUE
		int consolePrintTrue = 1;
		#else
		int consolePrintTrue = 0;
	#endif
	int consolePrintTarget = 2; // 2

	void consoleInit()
	{
		if(consoleInitialized) return;
		consoleInitialized = 1;
		AllocConsole();
		GConsoleBuffer = CreateConsoleScreenBuffer(GENERIC_WRITE, FILE_SHARE_READ, 0, CONSOLE_TEXTMODE_BUFFER, 0);
		SetConsoleActiveScreenBuffer(GConsoleBuffer);	
		//SetWindowPos( GConsoleBuffer, 0, -800, -100, 0, 0, SWP_NOSIZE | SWP_NOZORDER );
		//MoveWindow( GConsoleBuffer, -600, -100, 0, 0, TRUE);
	}

	void cdiag(char* AText)
	{
		if(!consolePrintTrue) return;
		if(consolePrintTarget) diag(AText);
		if(consolePrintTarget == 0 || consolePrintTarget == 2)
		{
			if(!consoleInitialized) consoleInit();
			WriteConsole(GConsoleBuffer, AText, str_len(AText), NULL, 0);
		}
	}
	
	#define cprintf0(str) cdiag(_chr(str)) // time to redo this with var args...
	#define cprintf1(str,arg1) cdiag(_chr(str_printf(NULL,str,arg1)))
	#define cprintf2(str,arg1,arg2) cdiag(_chr(str_printf(NULL,str,arg1,arg2)))
	#define cprintf3(str,arg1,arg2,arg3) cdiag(_chr(str_printf(NULL,str,arg1,arg2,arg3)))
	#define cprintf4(str,arg1,arg2,arg3,arg4) cdiag(_chr(str_printf(NULL,str,arg1,arg2,arg3,arg4)))
	#define cprintf5(str,arg1,arg2,arg3,arg4,arg5) cdiag(_chr(str_printf(NULL,str,arg1,arg2,arg3,arg4,arg5)))
	#define cprintf6(str,arg1,arg2,arg3,arg4,arg5,arg6) cdiag(_chr(str_printf(NULL,str,arg1,arg2,arg3,arg4,arg5,arg6)))
	#define cprintf7(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7) cdiag(_chr(str_printf(NULL,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)))
	#define cprintf8(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) cdiag(_chr(str_printf(NULL,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)))
	#define cprintf9(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9) cdiag(_chr(str_printf(NULL,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)))
	#define cprintf10(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10) cdiag(_chr(str_printf(NULL,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)))
#endif



It's crashing after "[...]effect %p" and before "b". Usually the console is on point (and the acklog).

Btw. bmap_process crashes when you call it each (/ the same) frame, have the material's AUTORELOAD flag set and save the *.fx file. I never really questioned it as I've thought some d3d pointer got invalid that frame at least but maybe... it actually shouldn't and there's something else going on?
Posted By: Superku

Re: bmap_process crashes - 01/01/19 17:00

Still getting crashes (that is one today, another one week(s) ago). Fixed a small memory (local array) issue and hoped the bmap_process crash was a subsequent issue of overwriting memory somewhere beforehand but no luck.

I've written my own bmap_process for now and that seems to be working. We'll see if that one crashes as well, if so I should be able to pinpoint the issue in there.
Posted By: Superku

Re: bmap_process crashes - 03/04/19 16:12

I've released my game on February 28th and sadly bmap_process causes issues on a bunch of machines, either just crashing the game or spewing file not found messages (regarding fxo files) - game installed in regular full ASCII paths.
It was showing the 255 WRS control byte in file names on some machines:
https://i.imgur.com/STsNIQ4.png
So I thought maybe it would go away when I put shaders not into the WRS, no difference though:
https://cdn.discordapp.com/attachments/430428194517155861/552159630982119424/unknown.png
https://i.imgur.com/mU4u3uu.png

My custom bmap_process had some issues as well, which I forgot sadly. I will have to look into it.
As I expected that that function may cause some trouble I had included a menu settings variable with which you can disable all bmap_process calls. That affects the main menu, in-level leaderboard and name display though. And people have to contact me first or find that info somewhere. Saw a bunch of refunds because of those issues.

Can you please look into bmap_process again? Something is not right about it. Maybe the fact that it crashes when you edit an fx file live could be a good starting point.
Thank you!!
Posted By: jcl

Re: bmap_process crashes - 03/04/19 16:57

I'll do that, but to be sure: the crashes happened when loading fxo files from the wrs? Or does it also happen with external fxo files?
Posted By: Superku

Re: bmap_process crashes - 03/05/19 00:01

Thank you already!
I've looked through everything for the 10th time after my post and only then realized there's 2 implicit effect_load calls (which I constantly overlooked) when I open the menu. Those were resulting in the file not found messages.
I loaded them via "effect_load(mat,mat->effect)", maybe that's the issue (why only on some machines though?). Happens to files read from a sub-folder or from the WRS.
The subsequent crash then probably came from an invalid effect.


The only remaining/ actual issues with bmap_process then are some crashes during level_load (which I circumvented using draw_obj and SetTexture/ ... calls) and editing FX files live. Which only is a bit annoying but not a big deal.
Posted By: jcl

Re: bmap_process crashes - 03/05/19 11:25

I did not find a bug in bmap_process, but I found one in effect_load. This command:

effect_load(mat,name)

should not get a pointer to mat->effect as second parameter. So if you want to reload the effect, store the name in a string or copy it to a char array and pass the copy. This is probably the reason of the errors in your screenshots.

Posted By: Superku

Re: bmap_process crashes - 03/06/19 16:18

Yes okay, thank you!

Unrelated, but the game does not launch on some machines (only a few though as far as I can tell). Apparently, it appears as a process in the task manager and that's it ("not responding").
Any idea what could be the issue there? I told them to try and install the DirectX 2010 runtime, currently waiting for results.
Posted By: jcl

Re: bmap_process crashes - 03/07/19 09:47

The DX 2010 runtime is normally not needed, since the DLLs are included in the distribution. At which point does it hang? Did the engine window already open?
Posted By: Superku

Re: bmap_process crashes - 03/07/19 12:56

Apparently they don't even see the starter window.

Quote:
the game would launch and on the task bar there would only be a blank box that would eventually show the face icon"32 ICO File" but the screenshot [of the starter window] you shared never would show

That person then tried the game with -diag set, and surprisingly it worked.
He had another issue though, that the game would get super slow (2-3 FPS) after playing for a short bit. Took ages to debug that. After showing me a video I noticed he had no sound.

Quote:
Hey so the problem was, for some stupid reason, my speakers were plugged into my motherboards back audio panel and its messed up somehow.
I didn't think that could cause a problem but my friend kept telling me that i should switch back to the front port cause the Nahimic 2+ audio drivers I'm using only work with the front panel;
so he changed it front the back to the front audio port and i started the game and it works properly now with audio.

I have not yet heard back from that guy if the game works without -diag as well now (EDIT: It doesn't, he has to use -diag). I'm using "-ns" in the starter window definition btw. (I only initialize my DirectSound8 implementation 3 frames after launch.)

No one of the other people with the same issue (game does not launch, "running in the background", not responding) have responded so far with more information.
© 2024 lite-C Forums