Source-Python-Dev-Team / Source.Python

This plugin aims to use boost::python and create an easily accessible wrapper around the Source Engine API for scripter use.
http://forums.sourcepython.com
GNU General Public License v3.0
163 stars 31 forks source link

Fixed referencing of released m_pCallingConvention on Source.Python unload. #387

Closed CookStar closed 3 years ago

CookStar commented 3 years ago

UnhookAllFunctions releases all m_pCallingConventions, but CFunctions held by AutoUnload such as EntityPreHook are not yet released, causing segmentation fault. https://github.com/Source-Python-Dev-Team/Source.Python/blob/89273cd840e601094f31ade3ef601ce3a95f012c/src/core/modules/memory/memory_function.cpp#L199 UnhookAllFunctions has been moved to the end to deal with this.

jordanbriere commented 3 years ago

Thanks, I was able to reproduce (not the crash, but the behaviours which I can see randomly leading to one). This also fixes potential issues if a plugin was dumb enough to register hooks in its unload method.