• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
darthvolvo

the basic tutorial crashes in 2.26.1

10 posts in this topic

Following the basic tutorial in the latest release, the program segfaults.

This is on 64-bit linux.

Valgrind output:
==4057== Memcheck, a memory error detector
==4057== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==4057== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==4057== Command: ./foo
==4057==
==4057== Invalid read of size 8
==4057==    at 0x4EC68C8: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) (in /usr/lib/libstdc++.so.6.0.9)
==4057==    by 0x4075E0: CopyConstructString(std::string const&, std::string*) (scriptstdstring.cpp:125)
==4057==    by 0x449A5F: X64_CallFunction(unsigned long const*, int, unsigned long (*)(), unsigned long&, bool) (as_callfunc_x64_gcc.cpp:142)
==4057==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==4057==
==4057==
==4057== Process terminating with default action of signal 11 (SIGSEGV)
==4057==  Access not within mapped region at address 0x0
==4057==    at 0x4EC68C8: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) (in /usr/lib/libstdc++.so.6.0.9)
==4057==    by 0x4075E0: CopyConstructString(std::string const&, std::string*) (scriptstdstring.cpp:125)
==4057==    by 0x449A5F: X64_CallFunction(unsigned long const*, int, unsigned long (*)(), unsigned long&, bool) (as_callfunc_x64_gcc.cpp:142)
==4057==  If you believe this happened as a result of a stack
==4057==  overflow in your program's main thread (unlikely but
==4057==  possible), you can try to increase the size of the
==4057==  main thread stack using the --main-stacksize= flag.
==4057==  The main thread stack size used in this run was 8388608.
==4057==
==4057== HEAP SUMMARY:
==4057==     in use at exit: 67,922 bytes in 366 blocks
==4057==   total heap usage: 766 allocs, 400 frees, 90,995 bytes allocated
==4057==
==4057== LEAK SUMMARY:
==4057==    definitely lost: 0 bytes in 0 blocks
==4057==    indirectly lost: 0 bytes in 0 blocks
==4057==      possibly lost: 35 bytes in 1 blocks
==4057==    still reachable: 67,887 bytes in 365 blocks
==4057==         suppressed: 0 bytes in 0 blocks
==4057== Rerun with --leak-check=full to see details of leaked memory
==4057==
==4057== For counts of detected and suppressed errors, rerun with: -v
==4057== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 5 from 5)
Code attached.
1

Share this post


Link to post
Share on other sites
Uploading didn't work, so pasting here.
#include "angelscript.h"
#include "scriptstdstring.h"
#include 
#include 

using namespace std;

void cb(const asSMessageInfo *msg, void *param) {

	const char *type = "ERR ";
	if (msg->type == asMSGTYPE_WARNING)
		type = "WARN ";
	else if (msg->type == asMSGTYPE_INFORMATION)
		type = "INFO ";

	printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type,
		msg->message);
}

void print(const string &in) {
	printf("%s\n", in.c_str());
}

const char mscript[] = "void main() { print(\"I believe!\"); }";

int main() {

	asIScriptEngine *ng = asCreateScriptEngine(ANGELSCRIPT_VERSION);

	int r;

	r = ng->SetMessageCallback(asFUNCTION(cb), 0, asCALL_CDECL);
	if (r < 0) printf("error %d\n", r);

	RegisterStdString(ng);

	r = ng->RegisterGlobalFunction("void print(const string &in)", asFUNCTION(print),
		asCALL_CDECL);
	if (r < 0) printf("error %d\n", r);

	// build
	asIScriptModule *mod = ng->GetModule("moi", asGM_ALWAYS_CREATE);
	mod->AddScriptSection("joo", mscript);

	r = mod->Build();
	if (r < 0) printf("error %d\n", r);

	// execute
	asIScriptFunction *f = mod->GetFunctionByDecl("void main()");
	if (!f)
		return 1;

	asIScriptContext *ctx = ng->CreateContext();
	ctx->Prepare(f);
	r = ctx->Execute();
	if (r < 0) printf("error %d\n", r);

	ng->Release();

	return 0;
}
BTW, I had to disable javascript to be able to post at all, the editor didn't let me to write anything in the text field. It refused to take focus.
0

Share this post


Link to post
Share on other sites

Thanks I'll look into it.

 

 

About the editor not working. You probably need to clear your browser cache. The last time GDNet upgraded the forum software I had a similar problem. Clearing the cache resolved it.

0

Share this post


Link to post
Share on other sites

Hmm. I couldn't reproduce this problem. 

 

I compiled the code you provided and ran it with valgrind as you did, but no problem was detected:

 

 

 
==17210== Memcheck, a memory error detector
==17210== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==17210== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==17210== Command: ./tutorial
==17210==
I believe!
==17210==
==17210== HEAP SUMMARY:
==17210==     in use at exit: 67,922 bytes in 366 blocks
==17210==   total heap usage: 766 allocs, 400 frees, 90,995 bytes allocated
==17210==
==17210== LEAK SUMMARY:
==17210==    definitely lost: 0 bytes in 0 blocks
==17210==    indirectly lost: 0 bytes in 0 blocks
==17210==      possibly lost: 35 bytes in 1 blocks
==17210==    still reachable: 67,887 bytes in 365 blocks
==17210==         suppressed: 0 bytes in 0 blocks
==17210== Rerun with --leak-check=full to see details of leaked memory
==17210==
==17210== For counts of detected and suppressed errors, rerun with: -v
==17210== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)

 

Observe, the memory leak that was detected is because you didn't release the context before existing. 

Edited by Andreas Jonsson
0

Share this post


Link to post
Share on other sites
Re leak:

I understand that a context cannot exist without the engine. It'd be logical for destroying the engine to also destroy the contexts, other frameworks I've used follow this principle. But this is not the main issue.

Re issue:

It's accessing a NULL pointer at that line. I'm not familiar with manually calling functions via asm, or even how to know which calling convention I should tell angelscript to use. Please advise.
0

Share this post


Link to post
Share on other sites
The manual calling evidently confuses gdb, but it's also causing the bug here - a NULL reference. That's not supposed to be possible in normal C++. Function in question:
static void CopyConstructString(const string &other, string *thisPointer)
{
        new(thisPointer) string(other);
}
gdb output breaking on it:
Breakpoint 1, CopyConstructString (other=@0x0, thisPointer=0xf64438) at scriptstdstring.cpp:125
125             new(thisPointer) string(other);
(gdb) bt full
#0  CopyConstructString (other=@0x0, thisPointer=0xf64438) at scriptstdstring.cpp:125
No locals.
#1  0x0000000000451874 in endstack ()
No symbol table info available.
#2  0x00007fff313eac00 in ?? ()
No symbol table info available.
#3  0x0000000000f52010 in ?? ()
No symbol table info available.
#4  0x00007fff313eac00 in ?? ()
No symbol table info available.
#5  0x00007fff313eab98 in ?? ()
No symbol table info available.
#6  0x0000000000434a8e in asCString::Assign ()
No symbol table info available.
#7  0x00007f00313eac80 in ?? ()
No symbol table info available.
#8  0x0000000000000001 in ?? ()
No symbol table info available.
#9  0x0000000000000000 in ?? ()
No symbol table info available.
0

Share this post


Link to post
Share on other sites

I understand that you're somehow getting a null pointer to the CopyConstructString, and it may very well be a bug in AngelScript. However, I ran the exact same code you posted on Linux 64bit with valgrind and couldn't reproduce the problem.

 

Did you get this problem with the code you posted, or do you have a different code? Would it be possible to attach the code you have for reproducing the problem, including the makefile you use? 

 

 

Also, did you upgrade from a previous version of AngelScript? Or is this the first time you've used it? If you did upgrade, can you do a clean build, i.e. remove all .obj files and then recompile everything?

0

Share this post


Link to post
Share on other sites
It's the exact code I use (with the exception of mangled includes, that was done by the GD forum software). This is the first time I'm using Angelscript, as I'm evaluating which scripting language to use in a project.

It was most certainly a clean build, and I've done various builds since with make clean in between. All show the issue.

I build it with "g++ -o foo foo.cpp scriptstdstring.cpp -Os -s -Wall -Wextra -langelscript".
0

Share this post


Link to post
Share on other sites

The problem is definitely related to the compiler optimizations. Compiling the library and application with any optimization flag except -O0 (no optimization) causes problems with 64bit. On 32bit, i.e compiling with -m32, all optimization modes work though.

 

I'll fix the problem with optimizations on 64bit as soon as I can. In the meantime, please turn off the optimizations when you're testing. 

0

Share this post


Link to post
Share on other sites

I found the problem. The compiler was optimizing away a local variable in X64_CallFunction because it didn't see that it was updated by the assembler code. 

 

I've checked in the fix in revision 1588. 

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0