[Home]

Summary:ASTERISK-23818: PBX_Lua: after asterisk startup module is loaded, but dialplan not available
Reporter:Dennis Guse (dennis.guse)Labels:
Date Opened:2014-06-04 07:46:43Date Closed:2014-08-06 11:44:54
Priority:MinorRegression?No
Status:Closed/CompleteComponents:PBX/pbx_lua
Versions:1.8.28.2 11.7.0 12.3.2 Frequency of
Occurrence
Related
Issues:
duplicatesASTERISK-24148 Can not use mysql at extensions.lua
duplicatesASTERISK-18230 sometimes dialplan switches disappear when merging contexts between pbx_lua and pbx_config
Environment:Ubuntu 14.04 64bit Linux x201 3.13.0-27-generic #50-Ubuntu SMP Thu May 15 18:06:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux Attachments:( 0) 23818-start.log
( 1) 23818-unload-load.log
( 2) extensions.conf
( 3) extensions.lua
( 4) sip.conf
Description:The pbx_lua module is loaded successfully on Asterisk startup, but the defined dialplan is not available, resulting in "extension unknown"-messages.

Using either: module reload pbx_lua.so
or module unload pbx_lua.so + module load pbx_lua.so
solves the problem as the configuration is loaded properly.

modules.conf was not changed (default from Ubuntu maintainers).
Most probable the configuration done by pbx_lua are overwritten by a component that is loaded later.
In addition, core reload does not kill the pbx_lua configuration...

------
Hi,

using the pbx_lua module for almost everything we have found a little annoying "bug". On Asterisk startup the module is loaded - however the configuration (extensions.lua) is not loaded and therefore the lua-defined dialplan is not available. By applying "module reload pbx_lua" the dialplan is loaded as expected (lua dialplan is correct).


------
How to reproduce the problem.

Details: Asterisk 11.7 running on Ubuntu 14.04

- Module is loaded on start
# asterisk -fvvv
..SNIP
[1;30m    -- [0mRegistered extension context 'default'; registrar: pbx_lua
[1;30m    -- [0mIncluding switch 'Lua/' in context 'default'
[1;30m    -- [0mRegistered extension context 'parkedcalls'; registrar: features
[1;30m    -- [0mmerging incls/swits/igpats from old(parkedcalls) to new(parkedcalls) context, registrar = pbx_lua
[1;30m    -- [0mAdded extension '700' priority 1 to parkedcalls
[1;30m    -- [0mTime to scan old dialplan and merge leftovers back into the new: 0.000043 sec
[1;30m    -- [0mTime to restore hints and swap in new dialplan: 0.000003 sec
[1;30m    -- [0mTime to delete the old dialplan: 0.000005 sec
[1;30m    -- [0mTotal time merge_contexts_delete: 0.000051 sec
[1;30m [0mpbx_lua.so => ( [0;33mLua PBX Switch [0m)
..SNIP

- Module is really loaded and thus fails:
#asterisk -rc "module load pbx_lua"

- Let the started Asterisk reload pbx_lua
# sudo asterisk -rxvvvvv
> module reload pbx_lua.so
   -- Reloading module 'pbx_lua.so' (Lua PBX Switch)
   -- Registered extension context 'default'; registrar: pbx_lua
   -- Including switch 'Lua/' in context 'default'
   -- Registered extension context 'parkedcalls'; registrar: features
   -- merging incls/swits/igpats from old(parkedcalls) to new(parkedcalls) context, registrar = pbx_lua
   -- Added extension '700' priority 1 to parkedcalls
   -- Registered extension context 'ael-builtin-h-bubble'; registrar: pbx_ael
   -- merging incls/swits/igpats from old(ael-builtin-h-bubble) to new(ael-builtin-h-bubble) context, registrar = pbx_lua
   -- Added extension 'h' priority 9996 to ael-builtin-h-bubble
   -- Added extension 'h' priority 9995 to ael-builtin-h-bubble
   -- Added extension 'h' priority 9994 to ael-builtin-h-bubble
   -- Added extension 'h' priority 9993 to ael-builtin-h-bubble
   -- Added extension 'h' priority 9992 to ael-builtin-h-bubble
   -- Added extension 'h' priority 9991 to ael-builtin-h-bubble
   -- Added extension 'h' priority 1 to ael-builtin-h-bubble
   -- Registered extension context 'ael-default'; registrar: pbx_ael
   -- merging incls/swits/igpats from old(ael-default) to new(ael-default) context, registrar = pbx_lua
   -- Including context 'ael-demo' in context 'ael-default'
   -- Registered extension context 'ael-demo'; registrar: pbx_ael
   -- merging incls/swits/igpats from old(ael-demo) to new(ael-demo) context, registrar = pbx_lua
...SNIP


----
Investigation:

I took a look into pbx/pbx_lua.c and actually "load" identical to reload + registering the module at Asterisk. Looks neat.
{code}
static int reload(void)
{
return load_or_reload_lua_stuff();
}

static int load_module(void)
{
int res;

if ((res = load_or_reload_lua_stuff()))
return res;

if (ast_register_switch(&lua_switch)) {
ast_log(LOG_ERROR, "Unable to register LUA PBX switch\n");
return AST_MODULE_LOAD_DECLINE;
}

return AST_MODULE_LOAD_SUCCESS;
}
{code}

----

Could it be that the pbx_lua is loaded to early and the dialplan overwritten by some other dialplan-module that is later loaded?

Comments:By: Rusty Newton (rnewton) 2014-06-09 17:20:06.166-0500

Please use these instructions: https://wiki.asterisk.org/wiki/display/AST/Collecting+Debug+Information

Collect a full debug log with verbose and debug types, turned up to 5 or above, for both the working "module load pbx_lua.so" and the Asterisk start up process where pbx_lua.so loads but doesn't get the dialplan.

Attach both of those to the issue. If possible, also attach your extensions.lua file so that we can reproduce.

By: Dennis Guse (dennis.guse) 2014-06-10 08:30:01.010-0500

Asterisk while loading pbx_lua.so, but the dialplan is not available.

By: Dennis Guse (dennis.guse) 2014-06-10 08:30:44.342-0500

Either reload or unload+load of pbx_lua.so loads the dialplan as expected.

By: Dennis Guse (dennis.guse) 2014-06-10 08:31:10.906-0500

Attached log-files.

By: Rusty Newton (rnewton) 2014-06-12 13:47:01.539-0500

Nope, you didn't provide what I asked, or follow the instructions. Try again, and please follow the instructions linked.

It looks like you collected your log from the console (including formatting garbage) instead of grabbing the log file itself. Plus there is no DEBUG messages.

By: Dennis Guse (dennis.guse) 2014-06-13 06:23:11.669-0500

Startup of Asterisk with missing lua-defined dialplan

By: Dennis Guse (dennis.guse) 2014-06-13 06:23:53.556-0500

Unload and load pbx_lua.so loads the dialplan as expected.

By: Dennis Guse (dennis.guse) 2014-06-13 06:24:17.435-0500

Attached log-files AFTER reading debug section...

By: Rusty Newton (rnewton) 2014-06-16 15:25:40.434-0500

[~dennis.guse] Thanks for grabbing the actual log files this time.. however you still didn't get a log file with "DEBUG" type messages included..

You need to look at the file before attaching to verify that it has not only the VERBOSE type messages, but DEBUG as well..

Can you also attach your extensions.lua file? Or at least a sample of it, with which the problem can be reproduced?

By: Rusty Newton (rnewton) 2014-06-16 15:39:40.406-0500

[~gtj] said he could take a look into this. Assigning to him. However we are still waiting on further feedback from Dennis.

By: George Joseph (gjoseph) 2014-06-16 16:16:18.189-0500

Dennis,
Looks like you installed the Ubuntu 11.7.0 package...
If there's a later package available, have you tried it?
Have you tried compiling from source?
If not and you have the ability to compile from source, can you give that a go with 11.10.2 and see if the problem still exists?

Also, what version of Lua do you have installed.

I'm trying these myself but it'd help if you tried them as well.

thanks.


By: George Joseph (gjoseph) 2014-06-17 00:12:57.346-0500

I just duplicated this on 12.3.2 so no further feedback needed.


By: Dennis Guse (dennis.guse) 2014-06-17 02:31:53.140-0500

@George: thanks for confirming the behavior.
If I can help further, just let me know.

By: George Joseph (gjoseph) 2014-06-17 14:58:12.101-0500

Dennis,

Can you check your modules.conf?   If you're doing a preload on any pbx_ modules, can you comment them out.  You can do noload on pbx_ modules you don't need but don't preload any of them.

I can get a good startup without the preloads but a bad startup by attempting to preload pbx_lua regardless of order.

Let me know.


By: George Joseph (gjoseph) 2014-06-17 17:08:57.724-0500

Hmmm.

I can reproduce the problem ONLY if I use preload in modules.conf.  I even spun up a Ubuntu 14.04 LTS 64bit VM and installed from apt-get using the default module.conf and it worked.

Dennis, if you don't have the preloads in, can you create a set of basic config files that'll reproduce the problem and attach them?

Thanks.

By: Dennis Guse (dennis.guse) 2014-06-18 03:09:08.233-0500

Configuration files that reproduce the problem on Ubuntu 14.04

Modules.conf could not be uploaded (Cannot attach file modules.conf: Unable to communicate with JIRA.) It is the default from 11.7.0~dfsg


{noformat}
;
; Asterisk configuration file
;
; Module Loader configuration file
;

[modules]
autoload=yes
;
; Any modules that need to be loaded before the Asterisk core has been
; initialized (just after the logger has been initialized) can be loaded
; using 'preload'. This will frequently be needed if you wish to map all
; module configuration files into Realtime storage, since the Realtime
; driver will need to be loaded before the modules using those configuration
; files are initialized.
;
; An example of loading ODBC support would be:
;preload => res_odbc.so
;preload => res_config_odbc.so
;
; If you want, load the GTK console right away.  
; Don't load the KDE console since
; it's not as sophisticated right now.
;
noload => pbx_gtkconsole.so
;load => pbx_gtkconsole.so
noload => pbx_kdeconsole.so
;
; Intercom application is obsoleted by
; chan_oss.  Don't load it.
;
noload => app_intercom.so
;
; The 'modem' channel driver and its subdrivers are
; obsolete, don't load them.
;
noload => chan_modem.so
noload => chan_modem_aopen.so
noload => chan_modem_bestdata.so
noload => chan_modem_i4l.so
;
; Comment this out (after installing CAPI middleware and hardware
; drivers) if you have CAPI-able hardware and wish to use it in
; Asterisk.
;
noload => chan_capi.so
;
load => res_musiconhold.so
;
; Load either OSS or ALSA, not both
; By default, load OSS only (automatically) and do not load ALSA
;
noload => chan_alsa.so
;noload => chan_oss.so
;
; Disable CDR logging to SQLite by default since it writes unconditionally to
; cdr.db without a way to rotate it.
;
noload => cdr_sqlite.so
;
; These conflict with app_directory.so and each other.
noload => app_directory_odbc.so
;
; Enable these if you want to configure Asterisk in a database
;
noload => res_config_odbc.so
noload => res_config_pgsql.so
;
; Module names listed in "global" section will have symbols globally
; exported to modules loaded after them.
;
[global]
{noformat}


By: George Joseph (gjoseph) 2014-06-18 08:13:12.463-0500

Thanks Dennis.  I can definitely reproduce the problem now.  

By: George Joseph (gjoseph) 2014-06-18 18:30:27.416-0500

Found the problem in the load order.   The patch is up on reviewboard.
It will apply to 1.8->11->12->trunk.


By: Timo Teräs (fabled) 2014-08-05 02:09:52.696-0500

Please revert the change to making pbx_lua.so symbols non-global. This completely broke lua modules (written in C).

The main binary is expected to export globally the lua_* symbols, so lua modules can use them.

See: http://lua-users.org/wiki/BuildingModules

Please fix this issue in an alternate way that does not break existing functionality.

By: Jeremy Lainé (sharky) 2014-08-05 05:39:03.030-0500

I agree with Timo, the change caused ASTERISK-17279 to reappear. Please note that bug was fixed precisely by using AST_MODFLAG_GLOBAL_SYMBOLS instead of AST_MODFLAG_DEFAULT.

By: George Joseph (gjoseph) 2014-08-05 09:15:01.734-0500

I'm investigating now.


By: George Joseph (gjoseph) 2014-08-05 12:46:33.605-0500

Ok, I now understand both issues better.   Patch that addresses both is forthcoming.


By: George Joseph (gjoseph) 2014-08-05 19:51:43.753-0500

I've uploaded a patch to reviewboard (link above) if anyone would care to test.