Hi!
I’m trying to load a scene XML in lua but Urho3DPlayer is segfaulting. Am I doing something wrong, or is this an issue that needs to be fixed?
I created a scene in Urho3D’s editor and saved it under Data/Scenes/ramps.xml.
Loading the scene using C++ works fine:
[code]void App::CreateScene()
{
ResourceCache* cache = GetSubsystem();
scene_ = SharedPtr<Scene>(new Scene(context_));
XMLFile* sceneFile = cache->GetResource<XMLFile>("Scenes/Ramps.xml");
scene_->LoadXML(sceneFile->GetRoot());
}[/code]
I then tried to re-write the above in Lua and ran it using Urho3DPlayer, but it segfaults.
function CreateScene()
scene_ = Scene()
local sceneXML = cache:GetResource("XMLFile", "Scenes/Ramps.xml")
scene_:LoadXML(sceneXML:GetRoot()) -- This line causes the segfault.
end
Exact command and backtrace:
[1] 2680 segmentation fault /usr/urho3d/bin/Urho3DPlayer MyScript.lua -w
#0 0x0000000000d877c4 in Urho3D::XMLFile::BeginLoad(Urho3D::Deserializer&) ()
#1 0x0000000000d94201 in Urho3D::Resource::Load(Urho3D::Deserializer&) ()
#2 0x0000000000d2a5f2 in Urho3D::Scene::LoadXML(Urho3D::Deserializer&) ()
#3 0x0000000000bf8955 in tolua_SceneLuaAPI_Scene_LoadXML01(lua_State*) ()
#4 0x0000000001184f07 in lj_BC_FUNCC ()
#5 0x0000000000a6d8bd in lua_pcall ()
#6 0x000000000104342f in Urho3D::LuaFunction::EndCall(int) ()
#7 0x000000000063117f in Urho3DPlayer::Start() ()
My version of Urho3D is on the master branch, commit hash 0906da48badacb227701e85b186581b580f9f778 (Fri Jan 15 21:02:56 2016 +0800). I built using the following options:
$ git clone git://github.com/urho3d/urho3d && cd urho3d
$ mkdir build && cd build
$ cmake \
-DURHO3D_C++11=ON \
-DURHO3D_DOCS=ON \
-DURHO3D_LUA=ON \
-DURHO3D_LUAJIT=ON \
-DCMAKE_INSTALL_PREFIX=/usr/urho3d \
..
$ make -j7
$ make install
OS:
$ uname -a
Linux rainbowdash 4.1.12-gentoo #1 SMP Tue Nov 10 00:33:50 CET 2015 x86_64 Intel(R) Core(TM) i5-2410M CPU @ 2.30GHz GenuineIntel GNU/Linux