YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

program crashes when i want to bind my classes and functions with sqrat
brightening-eyes
#1 Posted : Tuesday, September 22, 2015 6:06:29 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/21/2015(UTC)
Posts: 9
Man
Location: inside my computer

Thanks: 1 times
Was thanked: 0 time(s) in 0 post(s)
hello,
i want to register some stuff into my application, but it crashes
this is the debug log from GDB:
Code:

Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: F:\projects\cpp\advanced audio game engine\
Adding source dir: F:\projects\cpp\advanced audio game engine\
Adding file: F:\projects\cpp\advanced audio game engine\bin\Debug\aage.exe
Changing directory to: F:/projects/cpp/ADVANC~1/.
Set variable: PATH=.;C:\Dev-Cpp\bin;C:\Dev-Cpp;C:\Python34;C:\Python34\Scripts;C:\Program Files (x86)\cmake\bin;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Skype\Phone

[debug]Command-line: C:\Dev-Cpp\bin\gdb.exe -nx -fullname  -quiet  -args F:/projects/cpp/ADVANC~1/bin/Debug/aage.exe
[debug]Working dir : F:\projects\cpp\ADVANC~1

Starting debugger: C:\Dev-Cpp\bin\gdb.exe -nx -fullname  -quiet  -args F:/projects/cpp/ADVANC~1/bin/Debug/aage.exe
done

[debug]> set prompt >>>>>>cb_gdb:

Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints

[debug]Reading symbols from F:/projects/cpp/ADVANC~1/bin/Debug/aage.exe...
[debug]done.
[debug](gdb)
[debug]>>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.9.1
[debug]Copyright (C) 2015 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "i686-w64-mingw32".
[debug]Type "show configuration" for configuration details.
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]Find the GDB manual and other documentation resources online at:
[debug]<http://www.gnu.org/software/gdb/documentation/>.
[debug]For help, type "help".
[debug]Type "apropos word" to search for commands related to "word".
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.9.1

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source C:\Program Files (x86)\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory F:/projects/cpp/ADVANC~1/
[debug]Source directories searched: F:/projects/cpp/ADVANC~1;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> set args hello.aage -c -o hello.exe
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: F:\projects\cpp\ADVANC~1\bin\Debug\aage.exe hello.aage -c -o hello.exe

Child process PID: 11288

[debug][New Thread 11288.0x2ecc]
[debug][New Thread 11288.0x2d5c]
[debug][New Thread 11288.0x245c]
[debug][New Thread 11288.0x27d4]
[debug]Program received signal SIGSEGV, Segmentation fault.
[debug]0x004810a0 in SQVM::Push (this=0x0, o=...) at F:\projects\cpp\advanced audio game engine\src\squirrel\sqvm.cpp:1679
[debug]F:\projects\cpp\advanced audio game engine\src\squirrel\sqvm.cpp:1679:47819:beg:0x4810a0
[debug]>>>>>>cb_gdb:

Program received signal SIGSEGV, Segmentation fault.
At F:\projects\cpp\advanced audio game engine\src\squirrel\sqvm.cpp:1679

[debug]> bt 30
[debug]#0  0x004810a0 in SQVM::Push (this=0x0, o=...) at F:\projects\cpp\advanced audio game engine\src\squirrel\sqvm.cpp:1679
[debug]#1  0x0045deca in sq_pushroottable (v=0x0) at F:\projects\cpp\advanced audio game engine\src\squirrel\sqapi.cpp:506
[debug]#2  0x005fc27d in Sqrat::RootTable::RootTable (this=0x28f8c8, v=0x0) at F:/projects/cpp/advanced audio game engine/include/sqrat/sqratTable.h:451
[debug]#3  0x00401a57 in sq_OpenAI (state=0x37d0c0) at F:\projects\cpp\advanced audio game engine\src\AI.cpp:39
[debug]#4  0x00430c2e in WinMain@16 (hInst=0x400000, hPrevInst=0x0, cmdLine=0x18e3d9e "hello.aage -c -o hello.exe", showtype=10) at F:\projects\cpp\advanced audio game engine\src\main.cpp:230
[debug]#5  0x0070607d in main ()
[debug]>>>>>>cb_gdb:
[debug]> quit

Debugger finished with status 0


i'm using Code::Blocks 13.12 with GCC 5.1.0 from MinGW-w64
this is the code which register's the class:
Code:

void sq_OpenAI(HSQUIRRELVM state)
{
Class<KNearestNeighbor, NoCopy<KNearestNeighbor>> knn(state, _SC("knn"), true);
knn.Ctor<int, int>()
.Func(_SC("clear"), &KNearestNeighbor::clear)
.Func(_SC("exportFile"), &KNearestNeighbor::exportFile)
.Func(_SC("importFile"), &KNearestNeighbor::importFile)
.Func(_SC("saveFile"), &KNearestNeighbor::saveFile)
.Func(_SC("loadFile"), &KNearestNeighbor::loadFile)
.Func(_SC("calculate"), &KNearestNeighbor::calculate)
.Func(_SC("train"), &KNearestNeighbor::train)
.Func(_SC("optimizeTraining"), &KNearestNeighbor::optimizeTraining)
.Func(_SC("getNumberOfSamples"), &KNearestNeighbor::getNumberOfSamples);;
Class<MultilayerPerceptron, NoCopy<MultilayerPerceptron>> mlp(state, _SC("mlp"), true);
mlp.Ctor<int, int, float>()
.Func(_SC("calculate"), &MultilayerPerceptron::calculate)
.Func(_SC("get_result"), &MultilayerPerceptron::getResult)
.Func(_SC("feedback"), &MultilayerPerceptron::feedback)
.Func(_SC("set_learning_rate"), &MultilayerPerceptron::setLearningRate)
.Func(_SC("load_file"), &MultilayerPerceptron::loadFile)
.Func(_SC("save_file"), &MultilayerPerceptron::saveFile);
RootTable().Bind(_SC("knn"), knn);
RootTable().Bind(_SC("mlp"), mlp);
}


the classes don't have problems, the crash is from the registration
what do i have to do to fix them?
absence
#2 Posted : Thursday, September 24, 2015 2:46:24 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 8/23/2014(UTC)
Posts: 109
Man
Location: Northern Germany & Lincolnshire, U.K.

Thanks: 1 times
Was thanked: 10 time(s) in 10 post(s)
I use my own bindings and thus don't know sqrat, but your stack trace...

0x004810a0 in SQVM::Push (this=0x0, o=...) at F:\projects\cpp\advanced audio game engine\src\squirrel\sqvm.cpp:1679
[debug]#1 0x0045deca in sq_pushroottable (v=0x0) at F:\projects\cpp\advanced audio game engine\src\squirrel\sqapi.cpp:506
[debug]#2 0x005fc27d in Sqrat::RootTable::RootTable (this=0x28f8c8, v=0x0) at F:/projects/cpp/advanced audio game engine/include/sqrat/sqratTable.h:451
[debug]#3 0x00401a57 in sq_OpenAI (state=0x37d0c0) at F:\projects\cpp\advanced audio game engine\src\AI.cpp:39
[debug]#4 0x00430c2e in WinMain@16 (hInst=0x400000, hPrevInst=0x0, cmdLine=0x18e3d9e "hello.aage -c -o hello.exe", showtype=10) at F:\projects\cpp\advanced audio game engine\src\main.cpp:230
[debug]#5 0x0070607d in main ()


...tells that you try to access Squirrel without a valid VM. (v=0x0 whis is NULL!!!). So my best guess would be that you forgot to initialize Squirrel / SQRat properly before actually using it. Looks like sq_openAI (AI.cpp line 39 )passes a null pointer to Sqrats' RootTable constructor. As I said, I don't know Sqrat, but i suspect you should NOT construct the roottable that way - at least not with a null pointer ;-)

On a side note: You should do initialization before calling sq_OpenAI (because you really should pass the VM to use to make it match the API and stay independent of any other initialization stuff and especially initialization order).

In a nutshell: You use uninitialized stuff.
1 user thanked absence for this useful post.
brightening-eyes on 9/27/2015(UTC)
brightening-eyes
#3 Posted : Friday, September 25, 2015 3:24:10 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/21/2015(UTC)
Posts: 9
Man
Location: inside my computer

Thanks: 1 times
Was thanked: 0 time(s) in 0 post(s)
yes, you are wright
i've fixed it, but captcha haven't allowed me to post it
that should be RootTable(state) instead of RootTable()
again, thanks
absence
#4 Posted : Friday, September 25, 2015 8:25:41 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 8/23/2014(UTC)
Posts: 109
Man
Location: Northern Germany & Lincolnshire, U.K.

Thanks: 1 times
Was thanked: 10 time(s) in 10 post(s)
You're welcome.

(BTW, there's a "thank" button for each post ;-)
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.212 seconds.