Sign in to follow this  
Norman Barrows

what's this error message mean?

Recommended Posts

a beta tester for caveman 3.0 is getting the following error message at startup:

 

"When I launch caveman.exe, I just get the windows error that it's stopped

working with the following details:

Problem signature:
  Problem Event Name: BEX
  Application Name: caveman.exe
  Application Version: 0.0.0.0
  Application Timestamp: 53cd7824
  Fault Module Name: StackHash_4c4a
  Fault Module Version: 0.0.0.0
  Fault Module Timestamp: 00000000
  Exception Offset: 00000016
  Exception Code: c0000005
  Exception Data: 00000008
  OS Version: 6.1.7601.2.1.0.768.3
  Locale ID: 1033
  Additional Information 1: 4c4a
  Additional Information 2: 4c4ad7529a34983b6293625c48169922
  Additional Information 3: 4c4a
  Additional Information 4: 4c4ad7529a34983b6293625c48169922


Then, immediately after choosing "close the program", I get the same error
again, with these details:

Problem signature:
  Problem Event Name: BEX
  Application Name: caveman.exe
  Application Version: 0.0.0.0
  Application Timestamp: 53cd7824
  Fault Module Name: StackHash_2264
  Fault Module Version: 0.0.0.0
  Fault Module Timestamp: 00000000
  Exception Offset: 00000500
  Exception Code: c0000005
  Exception Data: 00000008
  OS Version: 6.1.7601.2.1.0.768.3
  Locale ID: 1033
  Additional Information 1: 2264
  Additional Information 2: 2264db07e74365624c50317d7b856ae9
  Additional Information 3: 875f
  Additional Information 4: 875fa2ef9d2bdca96466e8af55d1ae6e

 

 

 

Any idea how i can look up what this means?

 

It happens right at startup.

 

the code does a call to getsystemtime, then creates a window class, then creates a window, then creates a d3dobject, then it enumerates the 32bit ARGB resolutions supported by the default adapter, and selects the highest based on width, then height. but it doesn't check for the accompanying required depth stencil buffer format support.

 

there are windows message box error messages.displayed if create window class, create window, or create d3dobject fail. but the user doesn't even see these. so i'm thinking its something more fundamental, like insufficient ram or vidram, or unsupported depth stencil buffer format.

 

any ideas?

 

Share this post


Link to post
Share on other sites

it appears to be related to DEP on windows 7:

 

http://windows.microsoft.com/en-us/windows7/Change-Data-Execution-Prevention-settings?SignedIn=1

 

but when i try to exclude caveman.,exe from dep on my PC, it says the file can't be excluded from DEP!

 

caveman.exe works fine on my PC.

 

guess i have to put a trace on that exception code c000000005, which appears to be an access violation.

Share this post


Link to post
Share on other sites


It's almost certainly a NULL pointer.  Best of luck.

 

lovely!

 

both pcs are 64 bit windows 7.  other than drivers and such, the only difference appears to be DirectX version (works on 11, not on 12?). the code is dx9.0c. the code is also pre-OO c++, with stand alone functions and PODs, so no object init issues - except with windows and directx libraries.  but even there it's only using d3d9.lib, d3d9x.lib, winMM.lib, and x3daudio.lib, all statically linked. no 3rd party libs at all. 

 

well, i plan to post a new version that has optional startup progress messages. hopefully that will allow me to trace the problem.

Share this post


Link to post
Share on other sites
I'm on mobile, so no links, sorry! But:
A common thing to do is to install a SEH exception handler that produces a crash-dump.
If the user sends you this crash dump file, you can load it into your debugger and it'll look like your game has just ran/crashed on your own machine, letting you see the call-stack, state, etc...

As posted above, you're probably missing a piece of error handling somewhere and are trying to use a NULL pointer after some creation function has failed.

Share this post


Link to post
Share on other sites

So the error messaging that the program crashed due to an unhandled SEH exception with code C0000005. If you're not familiar with SEH, it's basically the low-level mechanism that Windows uses for handling critical failures caused by program behavior. For more information, I would suggest reading the Windows SDK documentation as well as the VC++ documentation.

 

In your particular case, the code of C0000005 corresponds to EXCEPTION_ACCESS_VIOLATION, which indicates that there was a memory access violation in your process or one of its loaded DLL's. Typically this happens due to accessing a pointer with a bad address, which is why mhagain suggested that it's probably due to a NULL pointer. That particular exception also comes with additional information telling you a bit more about what happened. In particular, it includes a flag indicating the memory access type and another integer containing the virtual address that was accessed. Your error report only includes the first parameter, the flag, and not the address. The flag has a value of 8, which tells us that the violation was caused by DEP, which is a feature that tries to make sure that programs don't start executing instructions that aren't part of the executable's actual code (it's meant to protect buffer overflows).

 

So it seems you've already figured out that DEP is involved, however you most definitely should not try to turn it off. You almost certainly have a bug in your code (or a DLL) that is caused your program to start executing from the wrong place in memory. There's a few ways that this can happen:

 

1. Using a bad function pointer

2. Stomping a vtable, and then calling a virtual function that uses the vtable

3. Trashing the stack in such a way that you don't return to the calling code of a function

 

Like Hodgman suggested, a good way to handle these problems is to write an exception handler (either by installing a global SEH handler, or by putting a __try/__except bracket around your main() function) and then write out a crash dump when the handler is invoked. You can have your beta tester send you the dump file, and then you can debug it on your machine to try to figure out what went wrong.

Share this post


Link to post
Share on other sites


So it seems you've already figured out that DEP is involved, however you most definitely should not try to turn it off. You almost certainly have a bug in your code (or a DLL) that is caused your program to start executing from the wrong place in memory.

 

yep, figured that out.   the first 5 hits from a google search on StackHash_2264 revealed that (if you read between the lines a bit).

 

my concern at this point is that it might not be in my code, but rather in windows or directx, but i find that hard to believe. OTOH, very little of my own code executes before the game goes fullscreen 3d, and the crash occurs before it goes fullscreen.

 

the only possible culprit that comes to mind is the autodetect code, which is currently hardcoded to handle a maximum of 50 32bit ARGB resolutions. so, if the primary adapter has more than 50 32bit ARGB resolutions supported, the autodetect code will cause an array overflow with no error checking and crash.  i assumed 50 would be more than enough, but perhaps that's not the case.  i suppose to be thorough and more bullet-proof, i should check for array full just in case.

 

i plan to post the code here, in hopes someone might spot a possible cause.

 

other than that, i'm waiting to hear back from the user, as i'm unable to reproduce the error here on my PC.

Share this post


Link to post
Share on other sites

ok, since there's not a lot of code between program launch and going into 3d mode, i'll post it, in hopes someone can spot something fishy.

 

i sometimes have difficulty with the editor when i intersperse code blocks in a posting, so please bear with me.

 

ok, step one: main()

 

int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
char s[1000];
strcpy_s(s,1000,lpCmdLine);
if (strcmp(s,"/d") == 0)
    {
    Zmsg("Running in debug mode","Caveman v3.0");
    Zdebug=1;
    }
else
    {
    Zdebug=0;
    }
nCmdShow=0;
hPrevInstance=0;
//  non-anti-crack     beta drm ---------------------------------------
#ifdef BETA
SYSTEMTIME _s;
int time1;
if (Zdebug)
    {
    Zmsg("Getting system time","Caveman v3.0");
    }
GetSystemTime(&_s);
if (Zdebug)
    {
    Zmsg("System time retrieved","Caveman v3.0");
    }
time1=_s.wYear*10000+_s.wMonth*100+_s.wDay;
if (time1 < BETA_START_DATE)
    {
    exit(1);
    }
if (time1 > BETA_END_DATE)
    {
    exit(1);
    }
#endif

cm_instance=hInstance;
//  checksum_exe calls initprog!
checksum_exe();
...
...

Share this post


Link to post
Share on other sites

step 2: checksum_exe:  does a checksum of the exe file, then calls initprog. the exe checksum code has been turned off via #ifdef.

 

void checksum_exe()
{
// code to do a checksum of the exe file goes here, but is turned off by #ifdef
if (!initprog(cm_instance))
    {
    Zmsg("Error initializing program","Caveman v3.0");
    exit(1);
    }
}
 

initprog: calls Zinit to start up the game library, then loads assets, etc.

 

int initprog(HINSTANCE instancehandle)
{
int a;
if ( ! Zinit(instancehandle,"Caveman v3.0",1.0f,1000) )   return(0);
...
...
 
Zinit: creates a window, starts up d3d, starts audio, etc.
 
int Zinit(HINSTANCE program_instance_handle,char *progname,float nearplane,int farplane) 
{
int a;
strcpy_s(Zprogram_name,100,progname);
if (! Zinitwindow(program_instance_handle)) return(0);
if (! Zinit3D(nearplane,farplane)) return(0);   
...
...
 
Zinitwindow: creates the program window
 
int Zinitwindow(HINSTANCE program_instance_handle)
// returns 1 on success, 0 on failure
{
ATOM result;
WNDCLASSEX wc;
char s[100];
ZeroMemory(&wc,sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;   // class style: CS_CLASSDC = one device context for all windows in the class.
wc.lpfnWndProc = Zmsgproc;
wc.hInstance=program_instance_handle,    // handle to program instance creating the class
wc.hCursor=LoadCursor(NULL, IDC_ARROW);   // cursor. null = no windows cursor, app will draw it.
// wc.hbrBackground = (HBRUSH)COLOR_WINDOW;    // background brush. null = none, app will draw background. 
                                               // set to zero so client area of game's window isn't drawn beefore going fullscreen.
strcpy_s(s,100,Zprogram_name);  // name of window class.
wc.lpszClassName=s;
if (Zdebug)
    {
    Zmsg("Registering window class","Caveman v3.0");
    }
result=RegisterClassEx( &wc );
if (result==0) 
  {
  Zmsg("Error registering window class",Zprogram_name);
  return(0);
  }
if (Zdebug)
    {
    Zmsg("Creating window","Caveman v3.0");
    }
Zprogram_window_handle=CreateWindowEx(WS_EX_TOPMOST,               // extended window style. WS_EX_TOPMOST=always on top. 0=no extended window style.
                                     Zprogram_name,     // window class name
                                     Zprogram_name,              // window name
                                     WS_POPUP,                    // window style. 
                                                                  // full screen: WS_POPUP = popup (no border, just client area)
                                                                  // windowed: WS_OVERLAPPEDWINDOW | WS_VISIBLE
                                     0,                           // UL corner x
                                     0,                           // UL corner y
                                     100,                    // screen_width // width
                                     100,                    // screen_height,               // height 
                                     NULL,                        // GetDesktopWindow(),   // handle of parent window. the desktop window is the parent.
                                     NULL,                        // menu handle. null = use window class's menu.
                                     program_instance_handle,     // program instance handle
                                     NULL);                       // pointer to additional data. null = no extra data.
if (Zprogram_window_handle==NULL) 
  {
  Zmsg("Error creating window",Zprogram_name);
  return(0);
  }
return(1);
}
 
Zinit3D: starts up d3d, inits pipeline, etc
 
int Zinit3D(float nearplane,int farplane)
{
HRESULT result; 
D3DXMATRIX m;
D3DMATERIAL9 material;
int a,width,height;
if (Zdebug)
    {
    Zmsg("Creating D3D object",Zprogram_name);
    }
d3d_obj_ptr=Direct3DCreate9(D3D_SDK_VERSION);
if (d3d_obj_ptr==NULL) 
    { 
    Zmsg("Error creating D3D object",Zprogram_name); 
    return(0); 
    }
do_adapter_stuff(&width,&height);
Zsetparams(width,height);
if (Zdebug)
    {
    Zmsg("Creating device",Zprogram_name);
    }
result=d3d_obj_ptr->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,Zprogram_window_handle,
                                 D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE,             // D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                 &Zparams,&Zd3d_device_ptr);
if (result != D3D_OK) { Zmsg("Error creating D3D device.",Zprogram_name); d3d_obj_ptr->Release(); return(0); }
// at this point its gone into fullscreen 3d mode, so its definitely crashing before it gets here
...
...
 
do_adapter_stuff: this is the autodetect routine. note that adapters with more than 50 32bit XRGB resolutions will cause an array range error. also note that i dont check depth stencil buffer format at all. i suppose i ought to fix both of those things, eh? the array range error is about the only thing i see in all this code that might cause the BEX error.
 
void do_adapter_stuff(int *w2,int *h2)
{
int num_adaptor_modes,i,w,h;
D3DDISPLAYMODE d[50];
HRESULT result;
FILE *f;
char s[100],s2[100];
if (filefound("startup_rez.dat"))
    {
    f=infile("startup_rez.dat");
    w=readfileint(f);
    h=readfileint(f);
    fclose(f);
    *w2=w;
    *h2=h;
    if (Zdebug)
        {
        i2s(w,s);
        strcat_s(s,100," x ");
        i2s(h,s2);
        strcat_s(s,100,s2);
        strcat_s(s,100," resolution specified in startup_rez.dat.");
        Zmsg(s,Zprogram_name);
        }
    return;
    }
if (Zdebug)
    {
    Zmsg("Getting adapter mode count",Zprogram_name);
    }
num_adaptor_modes=(int)d3d_obj_ptr->GetAdapterModeCount(D3DADAPTER_DEFAULT,D3DFMT_X8R8G8B8);
w=0; 
h=0;
if (Zdebug)
    {
    Zmsg("Enumerating adapter modes",Zprogram_name);
    }
for (i=0; i<num_adaptor_modes; i++)
    {
    result=d3d_obj_ptr->EnumAdapterModes(D3DADAPTER_DEFAULT,D3DFMT_X8R8G8B8,(UINT)i,&d[i]);
    if (result!= D3D_OK) d[i].Width=0;
    if ((int)d[i].Width>w)
        {
        w=(int)d[i].Width;
        h=(int)d[i].Height;
        }
    else if ((int)d[i].Width==w)
        {
        if ((int)d[i].Height>h) h=(int)d[i].Height;
        }
    }
if (Zdebug)
    {
    i2s(w,s);
    strcat_s(s,100," x ");
    i2s(h,s2);
    strcat_s(s,100,s2);
    strcat_s(s,100," resolution auto-selected.");
    Zmsg(s,Zprogram_name);
    }
*w2=w;
*h2=h;
}
 
Zsetparams: set the D3DPRESENT_PARAMETERS for the call to CreateDevice
 
void Zsetparams(int w,int h)
{
ZeroMemory(&Zparams,sizeof(D3DPRESENT_PARAMETERS));
Zparams.AutoDepthStencilFormat = D3DFMT_D24X8;
Zparams.BackBufferCount=1;
Zparams.BackBufferFormat = D3DFMT_A8R8G8B8;              // set the back buffer format to 32-bit      // turn these on for fullscreen
Zparams.BackBufferWidth = (unsigned)w;                          //width;    // set the width of the buffer
Zparams.BackBufferHeight = (unsigned)h;                          //height;    // set the height of the buffer
Zparams.EnableAutoDepthStencil = TRUE;                   // automatically run the z-buffer for us
Zparams.Flags=0;
Zparams.FullScreen_RefreshRateInHz=D3DPRESENT_INTERVAL_DEFAULT;
Zparams.hDeviceWindow=Zprogram_window_handle;
Zparams.MultiSampleQuality=0;
Zparams.MultiSampleType=D3DMULTISAMPLE_NONE;
Zparams.PresentationInterval=D3DPRESENT_INTERVAL_DEFAULT;
Zparams.SwapEffect = D3DSWAPEFFECT_COPY;                 //D3DSWAPEFFECT_DISCARD;
Zparams.Windowed = FALSE;                                // TRUE for windowed, FALSE for fullscreen
}
 
anyone see anything other than the 50 resolutions max, and no check for stencil format?
 
everything else look ok?
 
 
 
 
 

Share this post


Link to post
Share on other sites

As I understand it you first create an array with size 50 and then later fetch the list of supported display modes and fill them into the array.

 

What if you initialize the array directly with the list?

 

Like this (in SharpDX):

readonly DisplayMode[] dispModes = GraphicsAdapter.Default.GetOutputAt(0).SupportedDisplayModes;

Share this post


Link to post
Share on other sites

5 months later....

 

 

problem found!

 

create process error 740

 

the user has a problem with their user account controls - possible corrupt UAC permissions file.

 

so if you get a BEX or create process 740 error, it just might be the user's UAC system that's corrupt.

 

apparently, when Inno setup goes to launch the game, it gets an 740 error. Setup ought to be running at admin level for install, yet windows balks when an admin level app (setup) launches a non-admin level app (the game), apparently thinking the game requires admin level and thinking (somehow) that the user and setup are not running at admin level. this is merely conjecture as to whats going on. the bottom line is UAC isn't working right in such cases.

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this