[Home]

Summary:ASTERISK-26312: pbx_lua: Crash occurs when lua code executing
Reporter:Yuriy Topin (yuratop)Labels:
Date Opened:2016-08-23 07:10:09Date Closed:2020-01-14 11:13:49.000-0600
Priority:MinorRegression?
Status:Closed/CompleteComponents:PBX/pbx_lua
Versions:1.8.15.1 13.8.0 13.11.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Linux 3.19.0-66-generic #74-Ubuntu SMP Tue Jul 19 15:07:04 UTC 2016 x86_64 x86_64 x86_64 GNU/LinuxAttachments:
Description:Hi,
We uses asterisk and from time to time improve logic in extensions.lua. After some changes in extensions.lua, asterisk has been crached. I've tried to make some changes but realy for me not clear why after some changes in lua asterisk  craches.

I've tried different version of asterisk, try reinstall lua but without success.
Have found simillar question on the forum but it without answer.

Lua code example:



bt's output:
#0  0x00007ffff59b4267 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
#1  0x00007ffff59b5eca in __GI_abort () at abort.c:89
#2  0x00007ffff59f7c53 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7ffff5b101a8 "*** Error in `%s': %s: 0x%s ***\n")
   at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007ffff5a00391 in malloc_printerr (ptr=<optimized out>, str=0x7ffff5b0c2dd "corrupted double-linked list", action=1) at malloc.c:4965
#4  _int_free (av=0x7fff74000020, p=<optimized out>, have_lock=0) at malloc.c:3981
#5  0x00007ffff5a0389c in __GI___libc_free (mem=<optimized out>) at malloc.c:2950
#6  0x00007fff8f9d22d9 in l_alloc () from /usr/lib/asterisk/modules/pbx_lua.so
#7  0x00007fff8f9ca4fe in luaM_realloc_ () from /usr/lib/asterisk/modules/pbx_lua.so
#8  0x00007fff8f9ce868 in luaH_free () from /usr/lib/asterisk/modules/pbx_lua.so
#9  0x00007fff8f9c9455 in sweeplist () from /usr/lib/asterisk/modules/pbx_lua.so
#10 0x00007fff8f9ca231 in luaC_freeall () from /usr/lib/asterisk/modules/pbx_lua.so
#11 0x00007fff8f9cdafe in close_state () from /usr/lib/asterisk/modules/pbx_lua.so
#12 0x00007fff8f9c0c62 in lua_state_destroy (data=0x7fff74003520) at pbx_lua.c:129
#13 0x00000000004f91a1 in ast_datastore_free (datastore=0x7fff74001f30) at datastore.c:71
#14 0x00000000004b324f in ast_channel_destructor (obj=0x7fff6400d518) at channel.c:2209
#15 0x000000000045de08 in internal_ao2_ref (user_data=0x7fff6400d518, delta=-1, file=0x628cab "astobj2.c", line=516,
   func=0x628ed1 <__FUNCTION__.8824> "__ao2_ref") at astobj2.c:445
#16 0x000000000045e0b9 in __ao2_ref (user_data=0x7fff6400d518, delta=-1) at astobj2.c:516
#17 0x00000000004b4a26 in ast_hangup (chan=0x7fff6400d518) at channel.c:2692
#18 0x000000000057b121 in __ast_pbx_run (c=0x7fff6400d518, args=0x0) at pbx.c:4459
#19 0x000000000057b4f1 in pbx_thread (data=0x7fff6400d518) at pbx.c:4551
#20 0x0000000000601cd5 in dummy_start (data=0x7fff64012810) at utils.c:1237
#21 0x00007ffff649d6aa in start_thread (arg=0x7fff6cda9700) at pthread_create.c:333
#22 0x00007ffff5a85eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109


bt-full's output
#0  0x00007ffff59b4267 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
       resultvar = 0
       pid = 7323
       selftid = 7371
#1  0x00007ffff59b5eca in __GI_abort () at abort.c:89
       save_stage = 2
       act = {__sigaction_handler = {sa_handler = 0x200000000, sa_sigaction = 0x200000000}, sa_mask = {__val = {21163024, 140735019648224,
             8594514105, 21162992, 21162912, 140735019648592, 4583756, 32, 140735019648296, 104, 140734871177040, 326417514571, 51, 0, 21162992,
             140735019648368}}, sa_flags = 1946157088, sa_restorer = 0x5}
       sigs = {__val = {32, 0 <repeats 15 times>}}
#2  0x00007ffff59f7c53 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7ffff5b101a8 "*** Error in `%s': %s: 0x%s ***\n")
   at ../sysdeps/posix/libc_fatal.c:175
       ap = {{gp_offset = 40, fp_offset = 32767, overflow_arg_area = 0x7fff6cda87d0, reg_save_area = 0x7fff6cda8760}}
       fd = 22
       on_2 = <optimized out>
       list = <optimized out>
       nlist = <optimized out>
       cp = <optimized out>
       written = <optimized out>
#3  0x00007ffff5a00391 in malloc_printerr (ptr=<optimized out>, str=0x7ffff5b0c2dd "corrupted double-linked list", action=1) at malloc.c:4965
       buf = "00007fff74071b60"
       cp = <optimized out>
#4  _int_free (av=0x7fff74000020, p=<optimized out>, have_lock=0) at malloc.c:3981
       size = 176
       fb = <optimized out>
       nextchunk = <optimized out>
       nextsize = 1552
       prevsize = <optimized out>
       bck = <optimized out>
       fwd = <optimized out>
       errstr = 0x0
       locked = <optimized out>
#5  0x00007ffff5a0389c in __GI___libc_free (mem=<optimized out>) at malloc.c:2950
       ar_ptr = <optimized out>
       p = <optimized out>
       hook = <optimized out>
#6  0x00007fff8f9d22d9 in l_alloc () from /usr/lib/asterisk/modules/pbx_lua.so
No symbol table info available.
#7  0x00007fff8f9ca4fe in luaM_realloc_ () from /usr/lib/asterisk/modules/pbx_lua.so
No symbol table info available.
#8  0x00007fff8f9ce868 in luaH_free () from /usr/lib/asterisk/modules/pbx_lua.so
No symbol table info available.
#9  0x00007fff8f9c9455 in sweeplist () from /usr/lib/asterisk/modules/pbx_lua.so
No symbol table info available.
#10 0x00007fff8f9ca231 in luaC_freeall () from /usr/lib/asterisk/modules/pbx_lua.so
No symbol table info available.
#11 0x00007fff8f9cdafe in close_state () from /usr/lib/asterisk/modules/pbx_lua.so
No symbol table info available.
#12 0x00007fff8f9c0c62 in lua_state_destroy (data=0x7fff74003520) at pbx_lua.c:129
No locals.
#13 0x00000000004f91a1 in ast_datastore_free (datastore=0x7fff74001f30) at datastore.c:71
       res = 0
#14 0x00000000004b324f in ast_channel_destructor (obj=0x7fff6400d518) at channel.c:2209
       chan = 0x7fff6400d518
       vardata = 0x7fff6400d4c0
       f = 0x63728b
       headp = 0x53ccc6 <__ast_pthread_mutex_unlock+39>
       datastore = 0x7fff74001f30
       device_name = "\302/c\000\000\000\000\000\374Ac\000\000\000\000\000\260\212\332l\254\016\000\000\313\rc\000\000\000\000\000`\213\332l\377\177\000\000\370\324\000d\000\000\000\000 \213\332l\377\177\000\000A\331E\000\000\000\000\000Єc\000\000\000\000\000\030\325\000d\377\177\000"
       callid = 0x54265e <ast_log+343>
       __PRETTY_FUNCTION__ = "ast_channel_destructor"
#15 0x000000000045de08 in internal_ao2_ref (user_data=0x7fff6400d518, delta=-1, file=0x628cab "astobj2.c", line=516,
   func=0x628ed1 <__FUNCTION__.8824> "__ao2_ref") at astobj2.c:445
       obj = 0x7fff6400d4f8
       obj_mutex = 0x63728b
       obj_rwlock = 0x7fff6400d518
       current_value = 0
       ret = 1
       __PRETTY_FUNCTION__ = "internal_ao2_ref"
#16 0x000000000045e0b9 in __ao2_ref (user_data=0x7fff6400d518, delta=-1) at astobj2.c:516
       __FUNCTION__ = "__ao2_ref"
#17 0x00000000004b4a26 in ast_hangup (chan=0x7fff6400d518) at channel.c:2692
       __PRETTY_FUNCTION__ = "ast_hangup"
#18 0x000000000057b121 in __ast_pbx_run (c=0x7fff6400d518, args=0x0) at pbx.c:4459
       found = 1
---Type <return> to continue, or q <return> to quit---
       res = -1
       autoloopflag = 0
       error = 1
       pbx = 0x7fff74001c50
       callid = 0x0
       __PRETTY_FUNCTION__ = "__ast_pbx_run"
#19 0x000000000057b4f1 in pbx_thread (data=0x7fff6400d518) at pbx.c:4551
       c = 0x7fff6400d518
#20 0x0000000000601cd5 in dummy_start (data=0x7fff64012810) at utils.c:1237
       __cancel_buf = {__cancel_jmp_buf = {{__cancel_jmp_buf = {0, -4826640983371337144, 0, 140735207204863, 140735019653568, 0,
               -4826640983396502968, 4826322696954917448}, __mask_was_saved = 0}}, __pad = {0x7fff6cda8ef0, 0x0, 0x0, 0x0}}
       __cancel_routine = 0x45153f <ast_unregister_thread>
       __cancel_arg = 0x7fff6cda9700
       __not_first_call = 0
       ret = 0x0
       a = {start_routine = 0x57b4cc <pbx_thread>, data = 0x7fff6400d518,
         name = 0x7fff64014370 "pbx_thread", ' ' <repeats 11 times>, "started at [ 4577] pbx.c ast_pbx_start()"}
#21 0x00007ffff649d6aa in start_thread (arg=0x7fff6cda9700) at pthread_create.c:333
       __res = <optimized out>
       pd = 0x7fff6cda9700
       now = <optimized out>
       unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140735019652864, 4826321873244467784, 0, 140735207204863, 140735019653568, 0,
               -4826640983373434296, -4826338452604374456}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0,
             cleanup = 0x0, canceltype = 0}}}
       not_first_call = <optimized out>
       pagesize_m1 = <optimized out>
       sp = <optimized out>
       freesize = <optimized out>
       __PRETTY_FUNCTION__ = "start_thread"
#22 0x00007ffff5a85eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
No locals.



Comments:By: Asterisk Team (asteriskteam) 2016-08-23 07:10:10.553-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: Yuriy Topin (yuratop) 2016-08-23 07:11:05.470-0500

Lua code example:

function CD:sendVarsSetEvent()
   -- uuid
   -- parentUuid
   -- logicDirection
   -- legId
   -- legType
   -- leg2Id
   -- leg2Type
   -- otherLegName
   -- otherLegNum
   -- trunkNum

   local transferType = ""
   if self.funcs.TRANSFERERNAME and self.funcs.TRANSFERERNAME:get() then
       transferType = "attn"
   elseif self.funcs.BLINDTRANSFER and self.funcs.BLINDTRANSFER:get() then
       transferType = "blind"
   end

   local uid = self.funcs.UNIQUEID:get()
   local uuid = (self:getUUId() or "")
   local parentUuid = (self:getPersistParentUUId() or "")
   local direction = (self:getPersistLDirection() or "")
   local legId = (self:getPersistLegId() or "")
   local legType = (self:getPersistLegType() or "")
   local legId2 = (self:getPersistLegId2() or "")
   local legType2 = (self:getPersistLegType2() or "")
   local otherLegNum = (self:getPersistOtherLegNum() or "")
   local trunkNum = ""
   if self.funcs.CDR("channelnum") then
       trunkNum = self.funcs.CDR("channelnum"):get()
   end
   local transferHistory = (self:getPersistTransferHistory() or "")
   local label = (self:getPersistLabel() or "")

   self.apps.Macro("sendLogicVarsSet",uid,uuid,parentUuid,direction,legId,legType,legId2,legType2,otherLegNum,trunkNum,transferType,transferHistory,label)

   --self.apps.UserEvent(MANAGER_CUSTOM_EVENT.LOGIC_VARS_SET,"Uniqueid: " .. self.funcs.UNIQUEID:get() ..
   --    ",uuid: " .. (self:getUUId() or "") ..
   --    ",parentUuid: " .. (self:getPersistParentUUId() or "") ..
   --    ",logicDirection: " .. (self:getPersistLDirection() or "") ..
   --    ",legId: " .. (self:getPersistLegId() or "") ..
   --    ",legType: " .. (self:getPersistLegType() or "") ..
   --    ",leg2Id: " .. (self:getPersistLegId2() or "") ..
   --    ",leg2Type: " .. (self:getPersistLegType2() or "") ..
   --    ",otherLegName: " .. (self:getPersistOtherLegName() or "") ..
   --    ",otherLegNum: " .. (self:getPersistOtherLegNum() or "") ..
   --    ",trunkNum: " .. (self.funcs.CDR("channelnum"):get() or ""))
end

By: Rusty Newton (rnewton) 2016-08-24 18:08:25.534-0500

Thanks for the report! In order to maximize efficiently, there are project guidelines for how to report issues. Please read through the Asterisk Issue Guidelines [1]. After reading the guidelines, please clean up this issue so that bug marshals can more easily help you.

In particular:
1. Don't post extensive debug or logs inside the Description or Comment fields.
2. Use the Description field for a description of the issue, referencing *attached* debug with links or notes.
3. Use the Comment fields for discussion regarding the issue.
4. If you need to put a few lines of debug or logs into any field, surround the text with \{noformat\} tags to help us read it easily.
5. Attach files with a '.txt' extension where possible so that they can be analyzed futher by bug marshals.

Thanks!

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines



By: Asterisk Team (asteriskteam) 2016-09-08 12:00:00.824-0500

Suspended due to lack of activity. This issue will be automatically re-opened if the reporter posts a comment. If you are not the reporter and would like this re-opened please create a new issue instead. If the new issue is related to this one a link will be created during the triage process. Further information on issue tracker usage can be found in the Asterisk Issue Guidlines [1].

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines