lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi, list!

(This question contains some hardcore Adobe-specific details. If that
distracts you, please view it from the "unknown alpha-quality platform
with C compiler" point of view.)

I'm debugging a weird bug in the Lua Alchemy that appears with a
certain build configuration (with the same Alchemy SWC the bug appears
if AIR app built with FDT, and does not appear if built with raw AIR
SDK from command-line). In this case the Lua 5.1.4 code is built with
llvm-based Adobe Alchemy, to Flash bytecode, and that bytecode is then
translated to ARM code for iOS devices via latest AIR, all done by
Adobe pipeline, some of which is no longer supported alpha, so things
do get pretty weird.

I found that base_open() fails to set _G (i.e. lua_getglobal(L, "_G")
returns nil). See the code and the output below.

I'm a bit baffled. Maybe someone would have some idea on what else to
check from the C code side? Meanwhile I will continue to attack the
problem from "what is different between the FDT and SDK builds" side.

I assume that, at least, Alchemy compiler did not went nuts, since the
same SWC works in other configuration, but something in pipeline later
(like bytecode to ARM translator) maybe could... Or maybe I just doing
something somewhere that leads to undefined behaviour in C.

Thank you,
Alexander.

//
// This is what I changed in 5.1.4 code to debug what's happening:
//
static void base_open (lua_State *L) {
  /* set global _G */

  char buf[4096];

  sztrace("0057.1.0010 -- base_open BEGIN");

  lua_pushvalue(L, LUA_GLOBALSINDEX);

  sztrace("0057.1.0020");

  sprintf(buf, "0057.1.0021 L %p top type %s", L, luaL_typename(L, -1));
  sztrace(buf);

  sztrace("0057.1.0022");

  lua_setglobal(L, "_G");

  sztrace("0057.1.0023");

  lua_getglobal(L, "_G");

  sztrace("0057.1.0024");

  sprintf(buf, "0057.1.0025 L %p top type %s", L, luaL_typename(L, -1));
  sztrace(buf);

  sztrace("0057.1.0026");

  lua_pop(L, 1);

  sztrace("0057.1.0030");

  /* open lib into global table */
  luaL_register(L, "_G", base_funcs);
.... And at this point I see a segfault

My initialization function:
https://github.com/lua-alchemy/lua-alchemy/blob/ag/150/weird-bugs/alchemy/wrapper/lua_wrapper.gg#L32

The output:

0057.1.0010 -- base_open BEGIN
0057.1.0020
0057.1.0021 L 0x10e000 top type table
0057.1.0022
0057.1.0023
0057.1.0024
0057.1.0025 L 0x10e000 top type nil
0057.1.0026
0057.1.0030
RangeError: Error #1506: The specified range is invalid.
	at cmodule.lua_wrapper::FSM_newkey/work()
	at Function/<anonymous>()
	at Function/<anonymous>()
	at luaAlchemy::lua_wrapper$/luaInitializeState()[/Users/agladysh/projects/lua-alchemy/alchemy/wrapper/bin/src/luaAlchemy/lua_wrapper.as:7]
	at LuaAlchemyiOSTest/onCreationComplete()[/Users/agladysh/Documents/Adobe
Flash Builder 4.6/LuaAlchemyiOSTest/src/LuaAlchemyiOSTest.mxml:14]
	at LuaAlchemyiOSTest/___LuaAlchemyiOSTest_Application1_creationComplete()[/Users/agladysh/Documents/Adobe
Flash Builder 4.6/LuaAlchemyiOSTest/src/LuaAlchemyiOSTest.mxml:4]
	at flash.events::EventDispatcher/dispatchEventFunction()
	at flash.events::EventDispatcher/dispatchEvent()
	at mx.core::UIComponent/dispatchEvent()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:13152]
	at mx.core::UIComponent/set
initialized()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:1818]
	at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:842]
	at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1180]