Jump to content

  • Log In with Google      Sign In   
  • Create Account


darthvolvo

Member Since 04 Mar 2013
Offline Last Active Private
-----

Posts I've Made

In Topic: the basic tutorial crashes in 2.26.1

06 March 2013 - 05:11 AM

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".

In Topic: the basic tutorial crashes in 2.26.1

05 March 2013 - 10:37 AM

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.

In Topic: the basic tutorial crashes in 2.26.1

05 March 2013 - 10:28 AM

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.

In Topic: the basic tutorial crashes in 2.26.1

04 March 2013 - 03:34 PM

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.

PARTNERS