fix for raknet

iwanantonowitsch

06-03-2011 18:20:41

is anyone working on a fix for raknet and if so when would that be released?

andy

14-03-2011 05:24:58

Just want to check that you looked at the latest release (for Python 2.7) and that it still has an issue...

Am taking a look at Python 3.2 support so will have another look at Raknet then..

Regards
Andy

iwanantonowitsch

14-03-2011 09:13:03

Whoa really? youre porting the whole thing to py3k? that would be awesome!

Mohican

29-04-2011 14:07:22

Just want to check that you looked at the latest release (for Python 2.7) and that it still has an issue...


I've been using the 1.7.1 version, and can't get the Raknet Demos working either:

File "Demo_Chat_Server.py", line 157, in <module>
main()
File "Demo_Chat_Server.py", line 25, in main
i = server.GetNumberOfAddresses()
Boost.Python.ArgumentError: Python argument types in
RakPeer.GetNumberofAddresses(RakPeer)
did not match C++ signature:
GetNumberofAddresses(struct RakPeer_wrapper {lvalue})
GetNumberofAddresses(class RakPeer {lvalue})

Mohican

29-04-2011 15:49:34

I tried version 1.7.2, and Raknet is fixed in that version!

However, the 1.7.2 release misses some important components like ogreAL and Hydrax.
Do you plan to release the rest of the components for 1.7.2?

Thanks in advance!

iwanantonowitsch

30-04-2011 22:45:19

can those be mixed up? (yeah this question even sounds extremely stupid to me:D)

Mohican

04-05-2011 05:01:11

can those be mixed up? (yeah this question even sounds extremely stupid to me:D)

1.7.1 was built with python 2.6, wheras 1.7.2 was built with python 2.7
So there is no chance really...

iwanantonowitsch

04-05-2011 17:40:37

yeah i tested it anyways - it wasnt much of a surprise that it wouldnt work :D

Mohican

05-05-2011 15:50:31

I'm having some issues with RakNet.
It keeps crashing a few seconds after I initiate a connection to the localhost.
(The same application runs the server and client-side, they each have a separate rakpeer instance).

The crash happens even if no packets are exchanged.
I have attached the crash-dump files (in 4 parts due to forum rules).
Could one the devs take a look at it?

Thanks in advance! :wink:

PS: rename the extensions from .001.7z to .7z.001, and so on.

Mohican

05-05-2011 15:51:43

The next part.

Mohican

05-05-2011 15:57:26

I am also attaching my raknet code.

The application create one instance of each class (Server & Client).
Then it tries client.connectToServer()

The connection sequence is successfull.
But the application crashes after a few seconds, without any further exchange of packets taking place.

iwanantonowitsch

05-05-2011 23:15:08

what IDLE says to me when i start a server is:
Traceback (most recent call last):
File "C:\Program Files\OGRE\demos\raknet\Demo_Chat_Server.py", line 157, in <module>
main()
File "C:\Program Files\OGRE\demos\raknet\Demo_Chat_Server.py", line 25, in main
i = server.GetNumberOfAddresses()
ArgumentError: Python argument types in
RakPeer.GetNumberOfAddresses(RakPeer)
did not match C++ signature:
GetNumberOfAddresses(struct RakPeer_wrapper {lvalue})
GetNumberOfAddresses(class RakPeer {lvalue})

Mohican

06-05-2011 00:32:49

what IDLE says to me when i start a server is:

I only get this error message with 1.7.1.
Are you using 1.7.2?

iwanantonowitsch

07-05-2011 10:22:13

i'm using 1.7.1 but i'm happy to see you've got the same error so it's not just me.

EDIT: As everyone seems to have the same problem concerning pythonogre 1.7.1 and raknet it should be relatively easy to provide a fix, wouldn't it?

Mohican

09-05-2011 15:43:54

Andy, I really need help!

Raknet keeps crashing all the time.
I either get crashdump, as attached above, or an error message saying:

AttributeError: 'RakPeer' object has no attribute 'IsBanned'
Fatal Python error: GC object already tracked

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.


This error comes up while some other unrelated part of the program (randomly) is executing.
It looks like memory corruption... could you check for buffer overruns in the wrapper?

Mohican

10-05-2011 02:58:34

Found this interesting topic on the subject of the error I reported above: http://pyrit.wordpress.com/2010/02/18/385/
I wonder if the method causing the problems is: DeallocatePacket()
Maybe the underlying C code is interfering with the GC?

iwanantonowitsch

10-05-2011 11:04:28

Andy, I really need help!
THIS

Mohican

11-05-2011 10:13:58

Andy, can you PLEASE PLEASE PLEASE read this and help?

I have been trying to rebuild Raknet from the SVN Trunk.
I am using VS2005, Python 2.7.1, Ogre 1.7.2, Raknet 3.81.

So far, I have managed to rebuild completely OIS (I got _ois_.pyd).
All steps for Ogre 1.7.2 and Raknet complete succesfully, apart from the final linking.
I get unresolved symbols for both.

In the case of Raknet, it involes 2 symbols from the socketlayer class.
I tried to add socketlayer.cpp to the manual include list, but that made things worse (many more unresolved symbols).
I am guessing that there is a trick that you used in the Raknet code itself.

Can you please help me with getting the final step working?
I am on irc.freenode.org #python-ogre, all day Japan time.

Thanks!

iwanantonowitsch

11-05-2011 13:09:19

isnt there another networking library? i think previous pyogre versions had one.
[isnt there even a networking tool from the python community? *confusion*]

Mohican

11-05-2011 13:14:39

isnt there another networking library? i think previous pyogre versions had one.
[isnt there even a networking tool from the python community? *confusion*]


There are probably plenty.
A quick google search returned this one: http://mccormick.cx/projects/PodSixNet/

But the performance of such libraries will be nowhere near that of Raknet.
If you wanna program something for which network speed is important (like a FPS), then you really need raknet.

Mohican

11-05-2011 14:21:20

Good gracious God!
I finally did it, and got _raknet_.pyd compiled.
The additional_files list was all messed up, which caused the deluge of unresolved symbols.
Onto testing now... :-)

Mohican

11-05-2011 16:44:51

Ok, there's good news and bad news.

Good news is that I found what is causing the problem.
In RakPeer.cpp, there is a call to rakPeer::IsBanned()
This method is the one that crashes the app.

So it is possible to fix the crashes by simply commenting out a section of code in RakPeer.cpp:

bool ProcessOfflineNetworkPacket( const SystemAddress systemAddress, const char *data, const int length, RakPeer *rakPeer, RakNetSmartPtr<RakNetSocket> rakNetSocket, bool *isOfflineMessage, RakNetTimeUS timeRead )
{
(void) timeRead;
RakPeer::RemoteSystemStruct *remoteSystem;
Packet *packet;
unsigned i;

/* Commented to fix the crash bug in PO
#if !defined(_XBOX) && !defined(X360)
char str1[64];
systemAddress.ToString(false, str1);
if (rakPeer->IsBanned( str1 ))
{
for (i=0; i < rakPeer->messageHandlerList.Size(); i++)
rakPeer->messageHandlerList->OnDirectSocketReceive(data, length*8, systemAddress);

RakNet::BitStream bs;
bs.Write((MessageID)ID_CONNECTION_BANNED);
bs.WriteAlignedBytes((const unsigned char*) OFFLINE_MESSAGE_DATA_ID, sizeof(OFFLINE_MESSAGE_DATA_ID));
bs.Write(rakPeer->GetGuidFromSystemAddress(UNASSIGNED_SYSTEM_ADDRESS));

unsigned i;
for (i=0; i < rakPeer->messageHandlerList.Size(); i++)
rakPeer->messageHandlerList->OnDirectSocketSend((char*) bs.GetData(), bs.GetNumberOfBitsUsed(), systemAddress);
SocketLayer::Instance()->SendTo( rakNetSocket->s, (char*) bs.GetData(), bs.GetNumberOfBytesUsed(), systemAddress.binaryAddress, systemAddress.port, rakNetSocket->remotePortRakNetWasStartedOn_PS3 );

return true;
}
#endif
Commented to fix the crash bug in PO */

// The reason for all this is that the reliability layer has no way to tell between offline messages that arrived late for a player that is now connected,
// and a regular encoding. So I insert OFFLINE_MESSAGE_DATA_ID into the stream, the encoding of which is essentially impossible to hit by random chance
if (length <=2)
{
*isOfflineMessage=true;
}
else if (
((unsigned char)data[0] == ID_PING ||
(unsigned char)data[0] == ID_PING_OPEN_CONNECTIONS) &&
length == sizeof(unsigned char) + sizeof(RakNetTime) + sizeof(OFFLINE_MESSAGE_DATA_ID))
{
*isOfflineMessage=memcmp(data+sizeof(unsigned char) + sizeof(RakNetTime), OFFLINE_MESSAGE_DATA_ID, sizeof(OFFLINE_MESSAGE_DATA_ID))==0;
}



I will compile a release version, and make it available for download here.
The bad news is that I don't know boost well enough yet to understand what is wrong with this wrapper function:

virtual bool IsBanned( char const * IP ) {
namespace bpl = boost::python;
if( bpl::override func_IsBanned = this->get_override( "IsBanned" ) ){
boost::python::list py_IP;
// set a max inbound string length to ensure some level of saftey
int len_py_IP = strnlen ( IP, 4096 );
pyplus_conv::copy_container( IP, IP + len_py_IP, pyplus_conv::list_inserter( py_IP ) );
bpl::object py_result = bpl::call<bpl::object>( func_IsBanned.ptr(), IP );
return bpl::extract< bool >( pyplus_conv::get_out_argument( py_result, 0 ) );
}
else{
return RakPeer::IsBanned( IP );
}
}



Andy, do you have any clue just looking at it?

Mohican

11-05-2011 17:08:29

Ok guys, here is the "fixed" Raknet, with isBanned disabled: http://www.2shared.com/file/sSmHSv1A/ra ... 1-05-.html
Just delete the old files in ogre\addons\raknet, and unzip this archive to replace them.
NOTE: This will work only with Python-Ogre release 1.7.2-py27.

Please stop using this fix once Andy gets round to updating the SourceForge package.

iwanantonowitsch

11-05-2011 23:16:34

you are genius. ok, could someone now do the other packages?

Mohican

12-05-2011 03:34:42

I got another crash bug with IsActive().

So instead of doing more modifications to raknet itself, I reverted those changes and started making modifications to the wrapper.
I found that I can solve both isBanned() and isActive() crash bugs by commenting out code in RakPeer.pypp.cpp as follows:

virtual bool IsActive( ) const {
/* if( bp::override func_IsActive = this->get_override( "IsActive" ) )
return func_IsActive( );
else{
*/ return this->RakPeer::IsActive( );
// }
}

virtual bool IsBanned( char const * IP ) {
/* namespace bpl = boost::python;
if( bpl::override func_IsBanned = this->get_override( "IsBanned" ) ){
boost::python::list py_IP;
// set a max inbound string length to ensure some level of saftey
int len_py_IP = strnlen ( IP, 4096 );
pyplus_conv::copy_container( IP, IP + len_py_IP, pyplus_conv::list_inserter( py_IP ) );
bpl::object py_result = bpl::call<bpl::object>( func_IsBanned.ptr(), IP );
return bpl::extract< bool >( pyplus_conv::get_out_argument( py_result, 0 ) );
}
else{
*/ return RakPeer::IsBanned( IP );
// }
}


I am currently using debug binaries, until I find all such bugs.
When I am satisfied that I have found all methods causing crashes, I will recompile release binaries and link them here.

Mohican

12-05-2011 15:38:57

I think there are no more bugs.
I let my application run for several hours and it never crashed! ;-)

Here is a link to the latest release binaries: http://www.2shared.com/file/MLsBr6dK/ra ... 1-05-.html
Again, this is only for Python 2.7.1 + Python-Ogre 1.7.2.

iwanantonowitsch

13-05-2011 10:42:16

1) sry for beeing stupid
2) but what to do with those files?
3) thanks for reply and he fixes

Mohican

13-05-2011 11:10:45

In C:\Python27\lib\site-packages\ there should be a folder with python-ogre in the name.
Go in the subfolder \ogre\addons\raknet, delete the files in there, and unzip the archive to replace them.

iwanantonowitsch

13-05-2011 15:36:55

it wont work though... does it depend wheter i am 32 or 64 bit? or something else? i never had a raknet.dll before Oo

Mohican

13-05-2011 16:52:07

It does not depend on whether your platform is 32 or 64.
I need more information to help you: Please explain step-by-step how you installed Python-Ogre.

iwanantonowitsch

13-05-2011 22:11:35

1) got the core package
2) got media package
3) got every else package i needed
4) extracted everything
5) cmd -> setup.py install
6) run test applications -> YAY! it works (everything but raknet of course)

My folders after the extraction:
build
? lib
? ogre
? addons
? ? cadunetree
? ? caelum
? ? et
? ? hydrax
? ? noise
? ? ofusion
? ? ogreforests
? ? ogrevideo
? ? ogrevideoffmpeg
? ? particleuniverse
? ? plib
? ? raknet
? ? skyx
? gui
? ? betagui
? ? canvas
? ? CEGUI
? ? hikari
? ? mygui
? ? QuickGUI
? io
? ? OIS
? physics
? ? bullet
? ? ODE
? ? OgreBulletC
? ? OgreBulletD
? ? OgreNewt
? ? ogrenewt2
? ? OgreOde
? ? OgreRefApp
? ? Opcode
? ? PhysX
? renderer
? ? OGRE
? ? ogreoctreesm
? ? ogrepaging
? ? ogrepcz
? ? ogrertshadersystem
? ? ogresdksample
? ? ogreterrain
? ? plsm2
? sound
? OgreAL
? ogreoggsound
demos
? cegui
? ? datafiles
? ? ? configs
? ? ? fonts
? ? ? imagesets
? ? ? layouts
? ? ? looknfeel
? ? ? lua_scripts
? ? ? schemes
? ? ? xml_schemas
? ? tofix
? media
? ? DeferredShadingMedia
? ? ? DeferredShading
? ? ? material
? ? ? ? glsl
? ? ? ? hlsl
? ? ? post
? ? ? glsl
? ? ? hlsl
? ? fonts
? ? gui
? ? materials
? ? ? programs
? ? ? scripts
? ? ? textures
? ? ? nvidia
? ? models
? ? overlays
? ? packs
? ? particle
? ? PCZAppMedia
? ? RTShaderLib
? ? ? materials
? ? ssao
? ? thumbnails
? media_extra
? ? quake
? ? ? roadster
? ? ? textures
? ? shaders
? ? RenderMonkey
? ode
? ogre
? ? save
? ? tests
? ? tofix
? ogreode
? ? media
? ? ? materials
? ? ? ? scripts
? ? ? ? textures
? ? ? models
? ? ? packs
? ? tofix
? ? toworkon
? ogreoggsound
? ? media
? ogrepcz
? raknet
? samples
docs
packages_2.6
? ogre
? addons
? ? awesomium
? ? cadunetree
? ? caelum
? ? et
? ? hydrax
? ? noise
? ? ofusion
? ? ogredshow
? ? ogreforests
? ? ogrevideo
? ? ogrevideoffmpeg
? ? particleuniverse
? ? plib
? ? raknet
? ? skyx
? ? theora
? ? watermesh
? gui
? ? betagui
? ? canvas
? ? CEGUI
? ? hikari
? ? mygui
? ? navi
? ? QuickGUI
? io
? ? OIS
? physics
? ? bullet
? ? NxOgre
? ? ODE
? ? OgreBulletC
? ? OgreBulletD
? ? OgreNewt
? ? ogrenewt2
? ? OgreOde
? ? OgreRefApp
? ? Opcode
? ? PhysX
? renderer
? ? OGRE
? ? ogreoctreesm
? ? ogrepaging
? ? ogrepcz
? ? ogrertshadersystem
? ? ogresdksample
? ? ogreterrain
? ? plsm2
? sound
? OgreAL
? ogreoggsound
plugins
tools


I got only 2 files in the raknet folder: the __init__ and the _raknet_.pyd

Mohican

14-05-2011 08:59:12

You are using 1.7.1 right? Because the packages are for Python 2.6.
The fix only works with 1.7.2.

Anyhow, when you do "python setup.py install", it copies the python-ogre stuff to your python install folder (eg C:\Python26\lib\site-packages)
That's where the fixed raknet files need to be installed.

iwanantonowitsch

14-05-2011 15:33:20

sry for wasting your time... i misread this:
Again, this is only for Python 2.7.1 + Python-Ogre 1.7.2.
as this:
Again, this is only for Python-ogre 1.7.1 + Python-Ogre 1.7.2.



Ok, so what about the other packages? Could you get them working with py 2.7 and pyogre 1.7.2?

Mohican

15-05-2011 01:58:51

sry for wasting your time... i misread this:
Ok, so what about the other packages? Could you get them working with py 2.7 and pyogre 1.7.2?


Which packages do you need?
I can try if you only need one or two.

iwanantonowitsch

15-05-2011 10:26:52

as far as i can tell only ogreode but i'm sure it will be a mess to get it ready for 1.7.2. You should ask andy first because i think some fixes had to be made

Mohican

16-05-2011 10:57:01

I'll give it a go this week.
I also would like to build Hydrax, OgreAL and SkyX.

iwanantonowitsch

16-05-2011 14:29:32

You're right, OgreAL is missing, too. but i don't need it as soon as i need ogreODE