Jump to content

VS2019 Teleport crash


Go to solution Solved by Matteo,

Recommended Posts

Hi,

 

I have a client source and with vs2019 compatible Extern. The only thing i've got is crash when i try to teleport. When i start it in compatibility mode like Windows8, its totally working. If not, then crashing. I've investigated the crash with VS debugging, but i couldn't figure out what the heck is the problem, and how can i resolve it. Here's some pictures.

 

What do you guys think is wrong?

 

Kind Regards,

Minton

1.png

2.png

3.png

  • Metin2 Dev 1

System Administrator @ Hungarian Government
System Administrator @ Vibestro
Freelancer Developer @ Various projects

Link to comment
Share on other sites

  • Solution

Big thanks for @HITRON for the solution!

 

EterPythonLib/PythonWindowManager.cpp

 

Find: 

void CWindowManager::__ClearReserveDeleteWindowList()
{
	for (auto pWin : m_ReserveDeleteWindowList)
		delete pWin;
	m_ReserveDeleteWindowList.clear();
}

Replace:

void CWindowManager::__ClearReserveDeleteWindowList()
{
	// The above code not need, cause is cleaning it anyway from the vector i think.
	m_ReserveDeleteWindowList.clear();
}

#closerequest

  • Confused 1
  • Love 2

System Administrator @ Hungarian Government
System Administrator @ Vibestro
Freelancer Developer @ Various projects

Link to comment
Share on other sites

  • Honorable Member

How was that vector initialized? Never trust on an “i think”.

If it’s filled with raw pointers, a clear does not free the memory it points to. If it stores smart pointers than their lifetimes’ are managed.

Post the declarations, because there are many more reason for it. What problem you’ve fallen into is called dangling pointers. It occurs when you have invalidated pointers as their memory is freed but they are unable to check because they are not set to nullptr.

This can lead to a lot of other error because something is surely not okay there. Don’t hide the errors, solve them as it will just always get worse.

The easiest way is to store shared pointers and use weak pointers when you access any of the elements so that you can check their validity. If it’s a common base class consider making it usable with intrusive pointers as the specifications allow.

WRnRW3H.gif

Link to comment
Share on other sites

  • Bronze
1 hour ago, Distraught said:

How was that vector initialized? Never trust on an “i think”.

If it’s filled with raw pointers, a clear does not free the memory it points to. If it stores smart pointers than their lifetimes’ are managed.

Post the declarations, because there are many more reason for it. What problem you’ve fallen into is called dangling pointers. It occurs when you have invalidated pointers as their memory is freed but they are unable to check because they are not set to nullptr.

This can lead to a lot of other error because something is surely not okay there. Don’t hide the errors, solve them as it will just always get worse.

The easiest way is to store shared pointers and use weak pointers when you access any of the elements so that you can check their validity. If it’s a common base class consider making it usable with intrusive pointers as the specifications allow.

 

The problem actually happens from here:

 

	void CWindowManager::Update()
	{
		// If this code is commented is working fine.
		// __ClearReserveDeleteWindowList();

		// And add this instead:
		_ReserveDeleteWindowList.clear();

		m_pRootWindow->Update();
	}

 

So is happening when the CWindowManager is sending the Update() -> OnUIUpdate (PythonApplication), is not actually easy to follow this func to find what cause the problem, if @Minton could give us more info what he have added in his source and the problem appear would be nice.

Link to comment
Share on other sites

  • Bronze

First: I might understand why you replaced normal iterator type with auto but I don't understant why you replaced SAFE_DELETE macro with simple delete. You think who made that macro was stupid ?

Second: Your crash might be cause actually by that m_strName because is never initialized with a value (in debug it is) , and we know what happen when a variable is not initiallized in c++ ?

Link to comment
Share on other sites

  • Bronze
50 minutes ago, Johnny69 said:

First: I might understand why you replaced normal iterator type with auto but I don't understant why you replaced SAFE_DELETE macro with simple delete. You think who made that macro was stupid ?

Second: Your crash might be cause actually by that m_strName because is never initialized with a value (in debug it is) , and we know what happen when a variable is not initiallized in c++ ?

 

If he is using C++11 he can use the auto feature but i told him to try both ways to be sure the problem is not from the auto instead of iterator. The SAFE_DELETE(pWin) / delete pWin doesn't matter the problem won't fix that. m_strName If is not declared at first place is not belong in the list so isn't a problem.

Link to comment
Share on other sites

  • Honorable Member
2 hours ago, Minton said:

Don't forget that, it works in Win8 compatibility mode or Win7, but without the compatibility mode it is crashing.

 

You cannot rely on an “it works” neither. For example vc++ optimizes out overindexing an array in debug mode. Each compiler has its own routines. If something is only working in a specific environment than it’s not working.

WRnRW3H.gif

Link to comment
Share on other sites

  • Bronze
On 1/21/2020 at 4:14 AM, Distraught said:

 

You cannot rely on an “it works” neither. For example vc++ optimizes out overindexing an array in debug mode. Each compiler has its own routines. If something is only working in a specific environment than it’s not working.

 

Do you know any useful way to detect what exactly cause the problem and where?

Link to comment
Share on other sites

  • 3 weeks later...
  • Honorable Member
On 1/24/2020 at 5:56 AM, HITRON said:

 

Do you know any useful way to detect what exactly cause the problem and where?

Yep, it’s called debugger.

Btw you wrote a comment before you thought it could be caused by the auto keywords. Actually that’s exactly the same as you were writing iterators because the compiler interprets them what they are. Auto is not an actual type, just a shorthand. That’s why you have to initialize those variables at the same time to let the compiler know what it is going to be (except for decltype(auto)s, that got into the standard later for telling the compiler we don’t know the type yet but that’s neither a type as you can’t change after initialization).

WRnRW3H.gif

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.