[luatex] Lua Profiler
Philipp Stephani
st_philipp at yahoo.de
Mon May 16 16:38:34 CEST 2011
Am 16.05.2011 um 14:21 schrieb Reinhard Kotucha:
> On 2011-05-16 at 11:01:28 +0200, Philipp Stephani wrote:
>
>>
>> Am 16.05.2011 um 03:48 schrieb Reinhard Kotucha:
>>
>>> Hi,
>>> I compiled the Lua profiler from
>>>
>>> http://luaprofiler.luaforge.net
>>>
>>> and installed the shared library in $SELFAUTOLOC/lib .
>>>
>>> It works fine, except that the function profiler.start() ignores its
>>> argument (the name of the output file). It always creates a file
>>> lprof_<random number>.
>>>
>>> However, when I use the same shared library with stock Lua, I get
>>>
>>> Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
>>>> require('profiler')
>>>> profiler.start('foo')
>>>> print('hello')
>>> hello
>>>> profiler.stop()
>>>> os.exit()
>>> Segmentation fault (core dumped)
>>>
>>> Despite the segmentation fault, it creates a file
>>>
>>> -rw-r--r-- 1 reinhard users 333 May 16 02:57 foo
>>>
>>> at least.
>>>
>>> Did anybody encounter similar problems?
>>
>> Hello,
>>
>> how did you compile and install the profiler library? Does your
>> process differ in some way from the steps taken by LuaRocks? I'm
>> asking this because segmentation faults are typical on Unix-like
>> systems when an extension module is linked to a Lua library; so you
>> shouldn't link with e.g. -llua. If you installed the library via
>> LuaRocks and it crashes with stock Lua, then there's definitely a
>> bug somewhere in the library.
>
> Hi Philipp,
> I simply ran make -f Makefile.linux. It complained that I have to
> compile with -fPIC, so I added this to CFLAGS in config.linux and
> compiled again. Then I copied bin/profiler.so to $SELFAUTOLOC/lib and
> later to /usr/lib64/lua.
Seems all fine to me, and in fact I can reproduce your segfault. I'm quite sure this is a programming bug in the library code (use of the profiler state object after free).
>
> I didn't use LuaRocks because, according to its documentation, it
> tries to detect an installed Lua but I wanted to use the profiler with
> texlua anyway.
>
> Now I installed again with LuaRocks (nice tool) and don't get the
> segfault anymore.
Which is a bit surprising, but use-after-free bugs are not really deterministic.
More information about the luatex
mailing list