[SAMPGDK] Crashes(segmentation fault) when calling native. -
Max1548 - 03.12.2013
Hi all! Before i'll start, i wanna tell you about my bad english, sorry if any.
I'm using sampgdk for calling natives(i writing my gamemode, earlier i used invoke by Inkognito(sorry for mistakes) from Plugin development tutorial. I succefully installed sampgdk on my computer(linux ubuntu 12.04 32-bit). I included some sampgdk files and added libsampgdk.so to linker. When i calling in my GM any samp native fuction, it crashes(Segmentation fault), i have implemented my source as helloworld.cpp(on github of sampgdk).
I think: it's troubles with linking. What i have to do?
Sorry for my bad english, i lost my knowledge last year.
Thanks for reading!
Re: [SAMPGDK] Crashes(segmentation fault) when calling native. -
iZN - 03.12.2013
Segmentation fault error rises due to the files you've uploaded through FTP are in ASCII, try uploading them to binary mode which might fix your issue. Also this is not a correct board for this issue, it must be in
Server Support board.
Re: [SAMPGDK] Crashes(segmentation fault) when calling native. -
Max1548 - 03.12.2013
Quote:
Originally Posted by iZN
Segmentation fault error rises due to the files you've uploaded through FTP are in ASCII, try uploading them to binary mode which might fix your issue. Also this is not a correct board for this issue, it must be in Server Support board.
|
I'm testing GM on localhost.
Re: [SAMPGDK] Crashes(segmentation fault) when calling native. -
iZN - 03.12.2013
Quote:
Originally Posted by Max1548
I'm testing GM on localhost.
|
Could you try loading
nativechecker plugin? Also, it is better to post your codes at Scripting Discussion board. I believe it is something related to your code, I can't assist you further with C++ though.
Re: [SAMPGDK] Crashes(segmentation fault) when calling native. -
Max1548 - 03.12.2013
Quote:
Originally Posted by iZN
Could you try loading nativechecker plugin? Also, it is better to post your codes at Scripting Discussion board. I believe it is something related to your code, I can't assist you further with C++ though.
|
There aren't anything new in server log. Also i tried crashdetect-plugin but it didn't helps me. I'm sure that problems in my sampgdk connection. May be some additional libs which i have to add to linker?
Re: [SAMPGDK] Crashes(segmentation fault) when calling native. -
Mauzen - 03.12.2013
What native crashes it? And at which point exactly? Dont know about the sampgdk, but calling natives from other plugins (e.g. streamer) will most likely cause problems.
Re: [SAMPGDK] Crashes(segmentation fault) when calling native. -
xeeZ - 03.12.2013
Have you tried running the server under gdb?
Re: [SAMPGDK] Crashes(segmentation fault) when calling native. -
Max1548 - 03.12.2013
Quote:
Originally Posted by xeeZ
Have you tried running the server under gdb?
|
No.. But by using(sorry for my english) logprintf i have found that problem on calling Native.
First - on loading: CreateVehicle;
Second - SendClientMessage.
But it is interesting: GetPlayerName is calling without problems.
Re: [SAMPGDK] Crashes(segmentation fault) when calling native. -
xeeZ - 03.12.2013
Can you show the code?
Re: [SAMPGDK] Crashes(segmentation fault) when calling native. -
Max1548 - 03.12.2013
Quote:
Originally Posted by xeeZ
Can you show the code?
|
main.h - All libs, etc.
main.cpp - Main File.
BMPlayer.cpp - functions of class BMPlayer(e.g. SendMessage)
BMCars.cpp - LoadCars(function, which have a native CreateVehicle)
Re: [SAMPGDK] Crashes(segmentation fault) when calling native. -
xeeZ - 03.12.2013
OK, I think I've spotted the problem: you're calling CreateVehicle from Load <- this is bad, don't do that. Basically natives are not yet initialized when Load() gets called, so they are all just NULL at that point (hence the crash).
The solution is to use OnGameModeInit instead of Load.
Edit:
Actually there's even a bigger problem - you're calling LoadCars() before ByMsxRPMod.Load(), which initializes the GDK and its internal data structures (including the internal natives array), that's why you didn't get a nice error message telling you that CreateVehicle wasn't found instead of the segrault. Now I'm wondering why I didn't fix this...
Re: [SAMPGDK] Crashes(segmentation fault) when calling native. -
Max1548 - 03.12.2013
Quote:
Originally Posted by xeeZ
OK, I think I've spotted the problem: you're calling CreateVehicle from Load <- this is bad, don't do that. Basically natives are not yet initialized when Load() gets called, so they are all just NULL at that point (hence the crash).
The solution is to use OnGameModeInit instead of Load.
|
Ok, thanks. Big thanks!!!! Thank you!!!