RuntimeError: access violation - no RTTI data

All other Source.Python topics and issues.
Omega_K2
Senior Member
Posts: 227
Joined: Sat Jul 07, 2012 3:05 am
Location: Europe
Contact:

RuntimeError: access violation - no RTTI data

Postby Omega_K2 » Sun Sep 29, 2013 9:47 pm

Also posted on GitHub: https://github.com/Source-Python-Dev-Team/Source.Python/issues/2

It was though to find code that actually replicates this issue, because at first it seemed to happen quite randomly. There might be more cases then this one.

It seems to happen when passing/storing playerinfo objects to multiple functions; I'm guessing they go out of scope when the first function finishes execution:

To reproduce

Code: Select all

import command_c

def h(playerinfo, command):
    test(playerinfo)
    test(playerinfo)
   
def test(playerinfo):
    e = playerinfo.get_edict()
    e.get_index()
    print(e)

def load():
    command_c.register_client_command_filter(h)
   
def unload():
    command_c.unregister_client_command_filter(h)


Which will result in:

Code: Select all

<entity_c.CEdict object at 0x12345678>
(Traceback here)
RuntimeError: access violation - no RTTI data
Libraries: k2tools
Plugins (any): GSRPG (soon) | Pretty Status List | MySQLAds (soon)
Plugins (game-specific): None atm

If you happen to find a bug or need help, either post in the release threads or contact me in IRC gamesurge.net:6667 / #sourcepython
Omega_K2
Senior Member
Posts: 227
Joined: Sat Jul 07, 2012 3:05 am
Location: Europe
Contact:

Postby Omega_K2 » Mon Sep 30, 2013 4:12 am

Okay, it seems Python will garbage collect the edict instance because it thinks there are no more references to it, so solution is to either create a new object and return it OR make sure it doesn't get collected (adding __del__ should do that job, but it cause other problems):

So in fix players_wrap.cpp:

Code: Select all

CEdict* CPlayerInfo::get_edict() const
{
   return new CEdict(m_edict_ptr->get_edict());
}


See also: https://github.com/OmegaK2/Source.Python/tree/fixes
Libraries: k2tools

Plugins (any): GSRPG (soon) | Pretty Status List | MySQLAds (soon)

Plugins (game-specific): None atm



If you happen to find a bug or need help, either post in the release threads or contact me in IRC gamesurge.net:6667 / #sourcepython

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 65 guests