[Lazarus] SEGFAULT: difference between pointer and dynarray?
xrfang
xrfang at gmail.com
Sun Dec 30 14:50:11 CET 2012
Hi Sven,
I think that's the library we are talking about... However, make that call to @lr[0] will NOT fix the problem, as I mentioned in previous emails. To help you see what happened, I attach the debug log (from lazarus assembly window) again.
Also, it is very strange that my programs act very differently on Linux64 and Win32. On windows, even the "correct" version (which runs well on command line) will cause access violation in the IDE!
Thanks!
在 日, 12月 30, 2012 at 9:34 下午,Sven Barth <pascaldragon at googlemail.com> 写道:
On 30.12.2012 05:30, leledumbo wrote:
> Program received signal SIGSEGV, Segmentation fault.
> 0xb7e386d2 in ?? () from /lib/i386-linux-gnu/libc.so.6
> (gdb) bt
> #0 0xb7e386d2 in ?? () from /lib/i386-linux-gnu/libc.so.6
> #1 0xb7fa2d12 in ?? () from /usr/lib/i386-linux-gnu/liblua5.2.so.0
> #2 0xb7f95f09 in lua_setfield () from
> /usr/lib/i386-linux-gnu/liblua5.2.so.0
> #3 0xb7fa9a9a in luaL_setfuncs () from
> /usr/lib/i386-linux-gnu/liblua5.2.so.0
> #4 0x08066821 in LUAL_SETFUNCS (L=0x8071008, LR=..., highLR=1, NUP=0) at
> lua52.pas:835
> #5 0x080669e4 in LUAL_NEWLIB (L=0x8071008, LR=..., highLR=1) at
> lua52.pas:859
> #6 0x0804a3ea in main () at test.pas:31
>
> As you can see, the pointer changes when you pass an open array into another
> function expecting open array, even when static array is used (I've tried
> that one too). So, somebody with enough compiler knowledge should analyze
> this. Maybe you should create a bug report.
If the code of that lua52.pas is the one available here: http://lua-users.org/files/wiki_insecure/lua52.pas the error is understandable if one looks at the luaL_newlib function (the array overload):
=== source begin ===
procedure luaL_newlib(L: Plua_State; lr: array of luaL_Reg);
begin
luaL_newlibtable(L, lr);
luaL_setfuncs(L, @lr, 0);
end;
=== source end ===
The address of the open array parameter is passed, not the array to the first element. If you change the luaL_setfuncs call to
=== source begin ===
luaL_setfuncs(L, @lr[0], 0);
=== source end ===
it should work...
Regards,
Sven
--
_______________________________________________
Lazarus mailing list
Lazarus at lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20121230/5b63466a/attachment-0003.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: debug.txt
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20121230/5b63466a/attachment-0003.txt>
More information about the Lazarus
mailing list