Unhandled exception at 0x02D5C748

I`m getting exception during debugging:


Exception thrown at 0x02D5C748 in LoongDB.exe: 0xC0000005: Access violation executing location 0x02D5C748.

I`m trying to compile old game server.

So code that makes programm crash:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

// main.cpp

INT APIENTRY _tWinMain(HINSTANCE hInst, HINSTANCE, LPTSTR, INT)
{
    // ЅыЦ№ЖБД»±Ј»¤ј°µзФґ№ЬАн
    ::SystemParametersInfo(SPI_SETLOWPOWERTIMEOUT, 0, NULL, 0);
    ::SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, 0, NULL, 0);
    ::SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, 0, NULL, 0);

    vEngine::InitNetwork();
    vEngine::InitEngine();

#ifdef _DEBUG
    EXCEPTION_PROTECT;
#endif

    CLoong *pLoong = new CLoong;
    if(!pLoong->Init(hInst))
    {
        //іхКј»ЇК§°Ь
        SAFE_DEL(pLoong);
        ERR(_T("Loong init failed!"));
        return FALSE;
    }

    pLoong->MainLoop();

    SAFE_DEL(pLoong);

    vEngine::DestroyEngine();
    vEngine::DestroyNetwork();
    return 0;
}



// Loong.h (contains CLoong)

CLoong::CLoong()
{
    m_bTerminate            = FALSE;
    m_bGameServerLogout     = FALSE;
    m_bGameServerConnect    = FALSE;
    m_pDB                   = new CLoongDB;
    m_dwLogTime             = 0;
    m_szLogFilePostfix[0]   = '\0';


    ZeroMemory(m_szWorldName, sizeof(m_szWorldName));
    //ZeroMemory(m_szServerName, sizeof(m_szServerName));


    m_pLoadSimRole = new tagNDBS_LoadSimRole;   
    m_pCreateRole = new tagNDBS_CreateRole;     
    m_pLoadBaiBao = new tagNDBS_LoadBaiBao;     

    m_pLoadBaiBaoLog = (tagNDBS_LoadBaiBaoLog*)m_pBuffer;   


    m_pLoadRole = (tagNDBS_LoadRole *)m_pBuffer;


    m_Status.dwVerLoongDB       = LOONGDB_BUILD_REVISION;
    m_Status.dwVerBeton         = BETON_BUILD_REVISION;
    m_Status.dwVerVEngine       = VENGINE_BUILD_REVISION;
    m_Status.dwVerServerDefine  = SERVERDEFINE_BUILD_REVISION;
    m_Status.dwVerXML           = XMLREADER_BUILD_REVISION;


    m_MsgCmdMgr.Init();
}


OS - Windows 10
IDE - VS 2017
Compiler - c++ 14.1

So i found that error appears at

if(!pLoong->Init(hInst))
so seems like something wrong with

pLoong->Init(hInst)
Can someone please provide a solution or some sort of tips that will help me solve this?

UPD1:
hInst and pLoong is not null.

https://imgur.com/a/l73nBO5

I can't trace source of Init because it crushes right before going to it

Last edited on
I can only offer a very few suggestions as I can't even tell what software you're compiling.

First, though, to format code simply put your code between these tags:



[code]
[/code]


What operating system, IDE and compiler are you using?

Do you have a debugger? Can you use the debugger to trace into this call to see what's wrong?

For example, is pLoong a valid pointer or nullptr?

Is hInst valid?

Can you trace into the source of Init?
The key word here is “trace”.
Turn on your debugger and run your program. When it crashes it will tell you exactly which line caused the crash, and you can work from there.

BTW, clobbering a user’s power and screensaver settings is not very nice. You should first get them and then restore them before the program terminates. Make sure to set an abnormal exit handler to do it. If you are compiling with MSVC, use the MSVC-specific __try and __finally SEH handlers around main() to do it. If you are using GCC, make sure you have a .fini section to do it.

Also, whenever you are looking at making old code work on a new machine, you should always take a wander through the documentation to see what has changed. Since Vista you should be registering for power notifications.
https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-systemparametersinfoa

Hope this helps.
This line caused the crash
 
02BED280  mov         ecx,dword ptr ds:[726CC0h]  


The implication is that the problem happened before then, such that dword ptr ds:[726cc0h] is not a valid memory location to access.
I dont rly know how to fix it. Can u explain me with more details please?
You're making us repeat ourselves.
1. Is pLoong nullptr before the dereference?
2. Show your pLoong->Init function...
@rankery, I have only one instruction to work from, so I can't see any more than that. You need to be able to find a point before this failure in the code when the ds register is set, or when something at ds:[726cc0h] is being initialized. We simply have no other information out here.
compile it in debug mode. you get an assembly instruction because its using release code.
then once its compiled in debug mode, use your debugger to trap the error in real code.
if you are deep in the libraries, 'step out' until you are back in your code. that can also drop you to assembly -- you went too deep with the step-ins. you can also binary search your code.. put stops in it and run it, did it crash? If not, go farther, did it crash? find the offending line. It will be a memory/array/etc type access problem. perhaps zeromemory is misused?
Last edited on
@rankery, @jonnin is on to the plan, just wanted to say if you have the option in your debugger, you can use the "call stack" to see "how deep" you are into the libraries.

It shows you want in your code made the call that got into trouble.
Topic archived. No new replies allowed.