lua-users home
lua-l archive

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

Am 12.03.2010 16:21, schrieb Antonio Scuri:
Are you using IUP from LfW? That would be IUP 2. Can you try the same using the IUP 3 DLLs?
I just downloaded LuaForWindows_v5.1.4-33, extracted iuplua51.dll and iupdll to my testdirectory (i dont want to spoil my LuaForWindows_v5.1.4-30 installation yet),
changed package.cpath to point to my local folder and...
... the same crash. (Well not really the same, Crt now manages to show the error message before the exception, so it's a bit better, but I'll call it a crash anyway):

Microsoft Visual C++ Debug Library
Debug Assertion Failed!

Program: D:\MYPROJECTS\LuaDialog2\LuaDialog\Debug\LuaDialog.exe
File: dbgheap.c
Line: 1044

Expression: _CrtIsValidHeapPointer(pUserData)

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)
Abbrechen   Wiederholen   Ignorieren

So the problems remain the same...



-----Original Message-----
From: [mailto:lua-] On Behalf Of "J.Jørgen von Bargen"
Sent: sexta-feira, 12 de março de 2010 03:17
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");

      CString 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)";
          lua_pop(L, 1);

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


shows the alarm, but then get a "unhandled exception" inside the
lua_close. Interesting, even a


with no further code causes the crash.

The stacktrack shows up like this:

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
_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
freeobj(lua_State * 0x009a4d08, GCObject * 0x00cb4560) line 383 + 13
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

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