[SAMPGDK] Crashes(segmentation fault) when calling native.
#1

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!
Reply
#2

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.
Reply
#3

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.
Reply
#4

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.
Reply
#5

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?
Reply
#6

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.
Reply
#7

Have you tried running the server under gdb?
Reply
#8

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.
Reply
#9

Can you show the code?
Reply
#10

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)
Reply
#11

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...
Reply
#12

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!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)