Raised This Month: $32 Target: $400
 8% 

[SOLVED]Need help solving a segmentation fault(not srcds or hlds)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 05-22-2014 , 11:20   [SOLVED]Need help solving a segmentation fault(not srcds or hlds)
Reply With Quote #1

I'm working on this little c++ project for a friend of mine on Steam(I'm just porting Steambot(built on C#) to c++) and I've run into a little problem where I'm getting segmentation fault.
gdb reports the fault comes from this line:
Code:
		cmdHandler->FireCommand(msg);
the entire source is here: https://github.com/WildCard65/SteamB...ter/BotManager
the line in the code tags about is in this file: https://github.com/WildCard65/SteamB...ConsoleApp.cpp
Edit:
To compile:
  1. Make sure you got GTK3(not GTK2) and Boost Filesystem(Both if I read right, should be cross platform)
  2. For linux, run "cmake . -DISDEBUG=true" for windows, run "cmake -DISDEBUG=true", the -DISDEBUG=true just makes it compile into Bin/Debug folder.
  3. then run make(on linux) or nmake(on Windows, unless you got visual studios, then it'll just replace the solution file and make vs c++ projects)
To recreate seg fault, in the command line between "botmgr> " label and the button, type anything then either click button or hit enter on keyboard.

Last edited by WildCard65; 05-22-2014 at 15:27.
WildCard65 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-22-2014 , 14:42   Re: Need help solving a segmentation fault(not srcds or hlds)
Reply With Quote #2

C++ isn't my strong suit, but my best guess is that cmdHandler is NULL.

This is supported by this other line in ConsoleApp::ConsoleApp:
Code:
cmdHandler = cmdHandler;
which is a NOP and likely optimized out (I'm surprised you didn't get a warning from the compiler on this line).

Incidentally, this is one of the reasons you don't name your global and local variables with the same name.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-22-2014 at 14:47.
Powerlord is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 05-22-2014 , 15:24   Re: Need help solving a segmentation fault(not srcds or hlds)
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
C++ isn't my strong suit, but my best guess is that cmdHandler is NULL.

This is supported by this other line in ConsoleApp::ConsoleApp:
Code:
cmdHandler = cmdHandler;
which is a NOP and likely optimized out (I'm surprised you didn't get a warning from the compiler on this line).

Incidentally, this is one of the reasons you don't name your global and local variables with the same name.
I'll post results when I get there, funny thing though is the line it's faulting on still gets called.
Edit: Thx Powerlord, it fixed it(I changed the variable that is near top of cpp file for ConsoleApp to have a "L" infront(for local)

Last edited by WildCard65; 05-22-2014 at 15:26.
WildCard65 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:47.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode