<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div>Hi,</div><div><br></div><div><br></div><div>I am having a problem connecting to LDAP database from dialplan using lua script. When I run the below script from xml dialplan it causing a coredump and Freeswitch crashes.</div><div><br></div><div>The coredump looks like:</div><div><div><span class="Apple-style-span" style="background-color: rgb(255, 255, 255);"><font class="Apple-style-span" color="#ff0000">Core was generated by `/usr/local/freeswitch/bin/freeswitch -nonat -nc -heavy-timer'.</font></span></div><div><span class="Apple-style-span" style="background-color: rgb(255, 255, 255);"><font class="Apple-style-span" color="#ff0000">Program terminated with signal 11, Segmentation fault.</font></span></div><div><span class="Apple-style-span" style="background-color: rgb(255, 255, 255);"><font class="Apple-style-span"
color="#ff0000">#0 0x00002aaab6ff1720 in ldap_set_option () from /usr/lib64/libldap-2.3.so.0</font></span></div><div><span class="Apple-style-span" style="background-color: rgb(255, 255, 255);"><font class="Apple-style-span" color="#ff0000">(gdb) bt</font></span></div><div><span class="Apple-style-span" style="background-color: rgb(255, 255, 255);"><font class="Apple-style-span" color="#ff0000">#0 0x00002aaab6ff1720 in ldap_set_option () from /usr/lib64/libldap-2.3.so.0</font></span></div><div><span class="Apple-style-span" style="background-color: rgb(255, 255, 255);"><font class="Apple-style-span" color="#ff0000">#1 0x00002aaab6dbb68a in lualdap_open_simple () from /usr/local/lib/lua/5.1/lualdap.so</font></span></div><div><span class="Apple-style-span" style="background-color: rgb(255, 255, 255);"><font class="Apple-style-span" color="#ff0000">#2 0x00002aaab6b91704 in luaD_precall (L=0x14e12740, func=<value optimized
out>, nresults=-1) at ldo.c:319</font></span></div><div><span class="Apple-style-span" style="background-color: rgb(255, 255, 255);"><font class="Apple-style-span" color="#ff0000">#3 0x00002aaab6b9a4a4 in luaV_execute (L=0x14e12740, nexeccalls=1) at lvm.c:587</font></span></div><div><span class="Apple-style-span" style="background-color: rgb(255, 255, 255);"><font class="Apple-style-span" color="#ff0000">#4 0x00002aaab6b91b4e in luaD_call (L=0x14e12740, func=0x14e12b20, nResults=0) at ldo.c:377</font></span></div><div>#5 0x00002aaab6b912a7 in luaD_rawrunprotected (L=0x14e12740, f=0x2aaab6b8ed40 <f_call>, ud=0x409f4e00) at ldo.c:116</div><div>#6 0x00002aaab6b91325 in luaD_pcall (L=0xffffffffb002d5d0, func=0, u=0x2aaab002d5b8, old_top=46912585783072, ef=0) at ldo.c:463</div><div>#7 0x00002aaab6b8ebc5 in lua_pcall (L=0x14e12740, nargs=0, nresults=0, errfunc=<value optimized out>) at lapi.c:821</div><div>#8
0x00002aaab6b76d61 in docall (L=0x14e12740, narg=0, clear=1, perror=0) at mod_lua.cpp:91</div><div>#9 0x00002aaab6b77194 in lua_parse_and_execute (L=0x14e12740, input_code=0x2aaab004c220 "ldapdirectory.lua") at mod_lua.cpp:183</div><div>#10 0x00002aaab6b77e92 in lua_function (session=0x14e5bb68, data=<value optimized out>) at mod_lua.cpp:414</div><div>#11 0x00002b027ace8cd9 in switch_core_session_exec (session=0x14e5bb68, application_interface=0x2aaaac0622d8, arg=0x14d75968 "ldapdirectory.lua") at src/switch_core_session.c:2048</div><div>#12 0x00002b027ace9176 in switch_core_session_execute_application_get_flags (session=0xffffffffb002d5d0, app=0x14d758e8 "lua", arg=0x14d75968 "ldapdirectory.lua", flags=0x0) at src/switch_core_session.c:1962</div><div>#13 0x00002b027ad57a1a in CoreSession::execute (this=0x14d74d60, app=0x14d758e8 "lua", data=0x14d75968 "ldapdirectory.lua") at src/switch_cpp.cpp:658</div><div>#14 0x00002aaab6b861c0 in
_wrap_CoreSession_execute (L=0x2aaaac002050) at mod_lua_wrap.cpp:5678</div><div>#15 0x00002aaab6b91704 in luaD_precall (L=0x2aaaac002050, func=<value optimized out>, nresults=0) at ldo.c:319</div><div>#16 0x00002aaab6b9a4a4 in luaV_execute (L=0x2aaaac002050, nexeccalls=1) at lvm.c:587</div><div>#17 0x00002aaab6b91b4e in luaD_call (L=0x2aaaac002050, func=0x2aaaac012400, nResults=0) at ldo.c:377</div><div>#18 0x00002aaab6b912a7 in luaD_rawrunprotected (L=0x2aaaac002050, f=0x2aaab6b8ed40 <f_call>, ud=0x409f5800) at ldo.c:116</div><div>#19 0x00002aaab6b91325 in luaD_pcall (L=0xffffffffb002d5d0, func=0, u=0x2aaab002d5b8, old_top=46912585783072, ef=0) at ldo.c:463</div><div>#20 0x00002aaab6b8ebc5 in lua_pcall (L=0x2aaaac002050, nargs=0, nresults=0, errfunc=<value optimized out>) at lapi.c:821</div><div>#21 0x00002aaab6b76d61 in docall (L=0x2aaaac002050, narg=0, clear=1, perror=0) at mod_lua.cpp:91</div><div>#22 0x00002aaab6b77194 in
lua_parse_and_execute (L=0x2aaaac002050, input_code=0x14de5e00 "helloworld.lua") at mod_lua.cpp:183</div><div>#23 0x00002aaab6b77e92 in lua_function (session=0x14e5bb68, data=<value optimized out>) at mod_lua.cpp:414</div><div>#24 0x00002b027ace8cd9 in switch_core_session_exec (session=0x14e5bb68, application_interface=0x2aaaac0622d8, arg=0x14e2f368 "helloworld.lua") at src/switch_core_session.c:2048</div><div>#25 0x00002b027ace9176 in switch_core_session_execute_application_get_flags (session=0xffffffffb002d5d0, app=0x14e2f360 "lua", arg=0x14e2f368 "helloworld.lua", flags=0x0) at src/switch_core_session.c:1962</div><div>#26 0x00002b027acec4ad in switch_core_session_run (session=0x14e5bb68) at src/switch_core_state_machine.c:176</div><div>#27 0x00002b027ace8720 in switch_core_session_thread (thread=<value optimized out>, obj=0x14e5bb68) at src/switch_core_session.c:1271</div><div>#28 0x0000003ce900673d in start_thread () from
/lib64/libpthread.so.0</div><div>#29 0x0000003ce84d44bd in clone () from /lib64/libc.so.6</div><div><br></div><div><br></div><div>However if I run the same lua script from fs_cli it works fine. Can anyone please let me know what is going wrong when I call from the dialplan. Any help is greatly appreciated.</div><div><br></div><div>Thanks</div><div>Jyotshna</div><div><br></div></div><div><br></div><div><div>require "lualdap"</div><div>ld = assert (lualdap.open_simple ("192.168.2.xx"))<br></div><div><br></div><div><br></div><div>s= ld:search { base = "ou=People,dc=voalte,dc=com" , scope="subtree", filter = 'cn=A*', attrs = { "cn", "telephoneNumber" }}</div><div>for dn, attribs in s do</div><div> freeswitch.consoleLog("info",""..dn.."\n");</div><div> for name, values in pairs (attribs) do</div><div> -- stream:write("["..name.."] : ");</div><div><span class="Apple-tab-span" style="white-space:pre">
        </span>--stream:write (values);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>--stream:write ("\n");</div><div> end</div><div>end</div><div>assert(ld:close())</div><div><br></div></div></div></body></html>