Segfault when deleting a ship design

cordawyn
Junior Line Worker
Junior Line Worker
Posts: 2
Joined: Sat Dec 17, 2011 11:44 pm

Segfault when deleting a ship design

Postby cordawyn » Sat Dec 17, 2011 11:50 pm

Hi! When I go to the ship design screen, then press "load" and try to delete a ship design from the list, the game immediately segfaults. Somehow, it is not 100% reproducible, but I'd say, it would crash 9 times of 10. I'm using the 64-bit version of the game (v 1.56.0), on Ubuntu 11.10.
P.S.: This crash is not reproducible with a 32-bit version of the game.
User avatar
urkle
Supreme Robot
Supreme Robot
Posts: 130
Joined: Thu Dec 15, 2011 2:27 pm
Contact:

Re: Segfault when deleting a ship design

Postby urkle » Sun Dec 18, 2011 9:06 pm

cordawyn wrote:Hi! When I go to the ship design screen, then press "load" and try to delete a ship design from the list, the game immediately segfaults. Somehow, it is not 100% reproducible, but I'd say, it would crash 9 times of 10. I'm using the 64-bit version of the game (v 1.56.0), on Ubuntu 11.10.
P.S.: This crash is not reproducible with a 32-bit version of the game.


When it crashes did it delete the ship or is it still there?
Developing away on one of
Mac Pro Dual 2Ghz, 14GB RAM, Snow Leopard, nVidia 8800 512MB.
Linux, 8-core AMD, 8GB RAM, Fedora 18, nVidia 450 1GB
cordawyn
Junior Line Worker
Junior Line Worker
Posts: 2
Joined: Sat Dec 17, 2011 11:44 pm

Re: Segfault when deleting a ship design

Postby cordawyn » Thu Dec 22, 2011 5:32 pm

It's still there.
User avatar
urkle
Supreme Robot
Supreme Robot
Posts: 130
Joined: Thu Dec 15, 2011 2:27 pm
Contact:

Re: Segfault when deleting a ship design

Postby urkle » Fri Dec 23, 2011 2:57 pm

I've traced down the cause of this issue and am getting it fixed.
Developing away on one of
Mac Pro Dual 2Ghz, 14GB RAM, Snow Leopard, nVidia 8800 512MB.
Linux, 8-core AMD, 8GB RAM, Fedora 18, nVidia 450 1GB
offsides
Line Supervisor
Line Supervisor
Posts: 19
Joined: Thu Dec 15, 2011 3:02 pm

Re: Segfault when deleting a ship design

Postby offsides » Sat Dec 24, 2011 3:11 am

urkle wrote:I've traced down the cause of this issue and am getting it fixed.


If you don't mind my asking, what was the problem? Just curious...
User avatar
urkle
Supreme Robot
Supreme Robot
Posts: 130
Joined: Thu Dec 15, 2011 2:27 pm
Contact:

Re: Segfault when deleting a ship design

Postby urkle » Sat Dec 24, 2011 2:47 pm

offsides wrote:
urkle wrote:I've traced down the cause of this issue and am getting it fixed.


If you don't mind my asking, what was the problem? Just curious...



casting a pointer to an object into an "int" storage variable. There were some that I missed fixing apparently. that is why it only appeared in the 64bit build. and only sometimes.. Most likely you have a LOT more ram in your linux box than I have in mine (only 4GB here) so you system triggered it more frequently.
Developing away on one of
Mac Pro Dual 2Ghz, 14GB RAM, Snow Leopard, nVidia 8800 512MB.
Linux, 8-core AMD, 8GB RAM, Fedora 18, nVidia 450 1GB
offsides
Line Supervisor
Line Supervisor
Posts: 19
Joined: Thu Dec 15, 2011 3:02 pm

Re: Segfault when deleting a ship design

Postby offsides » Sat Dec 24, 2011 6:59 pm

urkle wrote:
offsides wrote:
urkle wrote:I've traced down the cause of this issue and am getting it fixed.


If you don't mind my asking, what was the problem? Just curious...



casting a pointer to an object into an "int" storage variable. There were some that I missed fixing apparently. that is why it only appeared in the 64bit build. and only sometimes.. Most likely you have a LOT more ram in your linux box than I have in mine (only 4GB here) so you system triggered it more frequently.


Only hit me once, but I haven't deleted many ship designs myself. I just wasn't sure what had been involved in porting the game to Linux, and figured this was an opportunity to find out a bit more :)

Thanks for the answer!
User avatar
urkle
Supreme Robot
Supreme Robot
Posts: 130
Joined: Thu Dec 15, 2011 2:27 pm
Contact:

Re: Segfault when deleting a ship design

Postby urkle » Sat Dec 24, 2011 9:23 pm

offsides wrote:
Only hit me once, but I haven't deleted many ship designs myself. I just wasn't sure what had been involved in porting the game to Linux, and figured this was an opportunity to find out a bit more :)

Thanks for the answer!


This is more of a "port to 64bit" issue than port to linux issue.

Basically the "practice" I see is this.

Code: Select all

typedef void CALLBACK(int data);
void Button::AddButtonCallback(CALLBACK *func, int data);

void myCallback(int data);

myButton->AddButtonCallback(myCallback, (int)someObjectPtr);


which is to allow any method to be registered as a callback when the button is clicked, and have some piece of "data" passed into the callback. However this is often an object pointer.. which works fine on 32bit as sizeof(void *) == sizeof(int).. However, 64bit sizeof(void *) != sizeof(int).. (8 != 4). This half of the pointer is lost.

So, there are two ways to solve this.. rewrite all reference to int data and (int)objptr) to long data and (long)objptr.. Or rewrite all those references to void*.

void* will be either 4 OR 8 depending on the architecture and long will be 4 or 8 depending on the architecture.

Another option would be to make it "long long" which will ALWAYS be 8 bytes regardless. And this is not the FIRST game I've had to do that with either. :) it's a common bad practice to case pointers into INT fields.

In reality the *BEST* option is to use void *.
Developing away on one of
Mac Pro Dual 2Ghz, 14GB RAM, Snow Leopard, nVidia 8800 512MB.
Linux, 8-core AMD, 8GB RAM, Fedora 18, nVidia 450 1GB
xian27
Junior Line Worker
Junior Line Worker
Posts: 2
Joined: Sun Dec 18, 2011 4:11 am

Re: Segfault when deleting a ship design

Postby xian27 » Sun Dec 25, 2011 10:18 am

I an being fun of making design I've traced down the cause of this issue and am getting it fixed...!
offsides
Line Supervisor
Line Supervisor
Posts: 19
Joined: Thu Dec 15, 2011 3:02 pm

Re: Segfault when deleting a ship design

Postby offsides » Mon Dec 26, 2011 2:12 am

urkle wrote:
offsides wrote:
Only hit me once, but I haven't deleted many ship designs myself. I just wasn't sure what had been involved in porting the game to Linux, and figured this was an opportunity to find out a bit more :)

Thanks for the answer!


This is more of a "port to 64bit" issue than port to linux issue.

Basically the "practice" I see is this.

Code: Select all

typedef void CALLBACK(int data);
void Button::AddButtonCallback(CALLBACK *func, int data);

void myCallback(int data);

myButton->AddButtonCallback(myCallback, (int)someObjectPtr);


which is to allow any method to be registered as a callback when the button is clicked, and have some piece of "data" passed into the callback. However this is often an object pointer.. which works fine on 32bit as sizeof(void *) == sizeof(int).. However, 64bit sizeof(void *) != sizeof(int).. (8 != 4). This half of the pointer is lost.

So, there are two ways to solve this.. rewrite all reference to int data and (int)objptr) to long data and (long)objptr.. Or rewrite all those references to void*.

void* will be either 4 OR 8 depending on the architecture and long will be 4 or 8 depending on the architecture.

Another option would be to make it "long long" which will ALWAYS be 8 bytes regardless. And this is not the FIRST game I've had to do that with either. :) it's a common bad practice to case pointers into INT fields.

In reality the *BEST* option is to use void *.


I've gotten bit by that type of assumption before (no pun intended). I'm a sysadmin by trade and not a programmer, but I hack enough code that I've dealt with things like this before. Thanks for the info!

Return to “Linux Support”

Who is online

Users browsing this forum: No registered users and 1 guest