lua-users home
lua-l archive

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


  Hi,

  Are you using IUP from LfW? That would be IUP 2. Can you try the same
using the IUP 3 DLLs?

Thanks,
scuri

> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-
> bounces@bazar2.conectiva.com.br] On Behalf Of "J.Jørgen von Bargen"
> Sent: sexta-feira, 12 de março de 2010 03:17
> To: lua@bazar2.conectiva.com.br
> Subject: exception when calling lua with iup
> 
> Hi folks!
> 
> This error originaly occurs in a big application, but to get a focus on
> in, I reproduced it in a small environment.
> Im using VisualStudio (VisualC++ 6.0). I created a standard dialog
> application with a text field and a button to call lua with the text.
> This is the relevant code:
> 
> void CLuaDialogDlg::OnDo()
> {
>      lua_State *L = lua_open();  /* create state */
>      if (L == NULL)
>      {
>          MessageBox("cannot create state: not enough memory");
>          return;
>      }
>      luaL_openlibs(L);
>      lua_register(L,"print",print);
> 
>      CString code;
>      GetDlgItemText(IDC_LUACODE,code);
>      int status=luaL_dostring(L,code);
> 
>      if (status && !lua_isnil(L, -1))
>      {
>          const char *msg = lua_tostring(L, -1);
>          if (msg == NULL) msg = "(error object is not a string)";
>          MessageBox(msg);
>          lua_pop(L, 1);
>      }
>      lua_close(L);
> }
> 
> This works fine for a lot of lua scripts. After fiddling the
> package.cpath and package.path (by adding a package.cpath="... lot of
> entries..." to the script) to point to my LuaForWindows installation I
> can also use lfs and other libs with no problems.
> 
> The trouble begins, when I try to use iuplua. The following code
> 
> require"iuplua"
> iup.Alarm('TITLE','TEXT','OK')
> 
> shows the alarm, but then get a "unhandled exception" inside the
> lua_close. Interesting, even a
> 
> require"iuplua"
> 
> with no further code causes the crash.
> 
> 
> The stacktrack shows up like this:
> 
> 00db26a0()
> USER32! 7e381923()
> USER32! 7e37b317()
> USER32! 7e3778d0()
> NTDLL! 7c91e473()
> USER32! 7e369402()
> USER32! 7e377611()
> USER32! 7e3749c4()
> USER32! 7e38a956()
> USER32! 7e38a2bc()
> USER32! 7e3b63fd()
> USER32! 7e3b64a2()
> USER32! 7e3a0877()
> USER32! 7e3a082f()
> __crtMessageBoxA(const char * 0x0012b198, const char * 0x004d5bfc
> `string', unsigned int 73746) line 65
> CrtMessageWindow(int 2, const char * 0x004d5198 `string', const char *
> 0x0012c2cc, const char * 0x00000000, const char * 0x0012e2f0) line 520
> +
> 22 bytes
> _CrtDbgReport(int 2, const char * 0x004d5198 `string', int 1044, const
> char * 0x00000000, const char * 0x004d52b4 `string') line 419 + 76
> bytes
> _free_dbg_lk(void * 0x00e41858, int 1) line 1044 + 40 bytes
> _free_dbg(void * 0x00e41858, int 1) line 1001 + 13 bytes
> free(void * 0x00e41858) line 956 + 11 bytes
> l_alloc(void * 0x00000000, void * 0x00e41858, unsigned int 32, unsigned
> int 0) line 631 + 9 bytes
> luaM_realloc_(lua_State * 0x009a4d08, void * 0x00e41858, unsigned int
> 32, unsigned int 0) line 79 + 27 bytes
> luaH_free(lua_State * 0x009a4d08, Table * 0x00cb4560) line 376 + 39
> bytes
> freeobj(lua_State * 0x009a4d08, GCObject * 0x00cb4560) line 383 + 13
> bytes
> sweeplist(lua_State * 0x009a4d08, GCObject * * 0x009a4d9c, unsigned int
> 4294967289) line 424 + 13 bytes
> luaC_freeall(lua_State * 0x009a4d08) line 487 + 18 bytes
> close_state(lua_State * 0x009a4d08) line 108 + 9 bytes
> lua_close(lua_State * 0x009a4d08) line 212 + 9 bytes
> CLuaDialogDlg::OnDo() line 224 + 9 bytes
> 
> After setting a breakpoint into CrtMessageWindow I could fetch the
> message
> 
> "Debug Assertion Failed!
> 
> Program: D:\MYPROJECTS\LuaDialog2\LuaDialog\Debug\LuaDialog.exe
> File: dbgheap.c
> Line: 1044
> 
> Expression: _CrtIsValidHeapPointer(pUserData)
> 
> So this looks to me, as if free is called with an invalid pointer, but
> there must be more memory corrupted, because the error message newer
> gets displayed.
> 
> Im using lua-5.1.4 from the source-tar statically linked, every other
> lib or dll is loaded via package from LuaForWindows_v5.1.4-30
> Can you give me any helpfull hints, how to fix (or avoid) the problem?
> 
> Regards