k4rthikr / unimrcp

Automatically exported from code.google.com/p/unimrcp
0 stars 0 forks source link

Application freeze upon call to mrcp_client_shutdown #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

  Create a client using unimrcp_client_create, create a log instance,
activate a log external handler, create an application using
mrcp_client_application_register, start the client using mrcp_client_start,
wait for it to start, create a bunch of sessions, then destroy all of them,
destroy the application using mrcp_application_destroy, destroy the log
instance using apt_log_instance_destroy, shutdown client using
mrcp_client_shutdown this call never returns. The last thing to do would be
the call to mrcp_client_destroy, unfortunately the code never reaches this
point.

What version of the product are you using? On what operating system?

I use the latest (trunk) libunimrcpclient version.
The OS is a Windows Server 2003 SP2 Enterprise Edition.

Please provide any additional information below.

Here is my application trace from the UniMRCP perspective. Please feel free
to ask any additional information you may need. Thanks in advance.

(01 13:29:33.890) 6100 - Create Application
(01 13:29:34.078) 6100 - Register Application [SAUniMRCP]
(---------------) 6100 - Start MRCP Client
(---------------) 3964 - Start SofiaSIP Agent
(---------------) 3964 - Start TCP/MRCPv2 Connection Agent
(---------------) 3964 - Start Media Processing Engine
(---------------) 3964 - MRCP Client Started
(---------------) 5076 - Receive SIP Event [nua_r_set_params] Status 200 OK
(01 13:29:34.140) 1116 - Create MRCP Handle 0x46a8fc0 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46aafc8 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46acfd0 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46aefd8 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46b0fe0 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46b2fe8 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46b4ff0 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46b6ff8 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46b9000 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46bb008 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46bd010 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46bf018 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46c1020 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46c3028 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46c5030 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46c7038 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46c9040 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46cb048 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46cd050 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46cf058 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46d1060 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46d3068 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46d5070 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46d7078 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46d9080 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46db088 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46dd090 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46df098 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46e10a0 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46e30a8 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46e50b0 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46e70b8 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46e90c0 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46eb0c8 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46ed0d0 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46ef0d8 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46f10e0 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46f30e8 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46f50f0 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46f70f8 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46f9100 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46fb108 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46fd110 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x46ff118 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x4701120 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x4703128 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x4705130 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x4707138 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x4709140 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x470b148 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x470d150 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x470f158 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x4711160 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x4713168 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x4715170 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x4717178 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x4719180 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x471b188 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x471d190 [MRCPv2-Default]
(---------------) 1116 - Create MRCP Handle 0x471f198 [MRCPv2-Default]
(01 13:33:59.812) 6100 - Destroy MRCP Handle 0x46e50b0 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46e70b8 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46e90c0 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46eb0c8 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46ed0d0 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46ef0d8 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46f10e0 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46f30e8 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46f50f0 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46f70f8 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46f9100 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46fb108 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46fd110 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46ff118 <new>
(---------------) 6100 - Destroy MRCP Handle 0x4701120 <new>
(---------------) 6100 - Destroy MRCP Handle 0x4703128 <new>
(---------------) 6100 - Destroy MRCP Handle 0x4705130 <new>
(---------------) 6100 - Destroy MRCP Handle 0x4707138 <new>
(---------------) 6100 - Destroy MRCP Handle 0x4709140 <new>
(---------------) 6100 - Destroy MRCP Handle 0x470b148 <new>
(---------------) 6100 - Destroy MRCP Handle 0x470d150 <new>
(---------------) 6100 - Destroy MRCP Handle 0x470f158 <new>
(---------------) 6100 - Destroy MRCP Handle 0x4711160 <new>
(---------------) 6100 - Destroy MRCP Handle 0x4713168 <new>
(---------------) 6100 - Destroy MRCP Handle 0x4715170 <new>
(---------------) 6100 - Destroy MRCP Handle 0x4717178 <new>
(---------------) 6100 - Destroy MRCP Handle 0x4719180 <new>
(---------------) 6100 - Destroy MRCP Handle 0x471b188 <new>
(---------------) 6100 - Destroy MRCP Handle 0x471d190 <new>
(---------------) 6100 - Destroy MRCP Handle 0x471f198 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46a8fc0 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46aafc8 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46acfd0 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46aefd8 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46b0fe0 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46b2fe8 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46b4ff0 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46b6ff8 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46b9000 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46bb008 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46bd010 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46bf018 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46c1020 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46c3028 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46c5030 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46c7038 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46c9040 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46cb048 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46cd050 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46cf058 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46d1060 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46d3068 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46d5070 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46d7078 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46d9080 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46db088 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46dd090 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46df098 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46e10a0 <new>
(---------------) 6100 - Destroy MRCP Handle 0x46e30a8 <new>
(---------------) 6100 - Destroy Application
(---------------) 6100 - Terminate MRCP Client
(---------------) 3964 - Terminate SofiaSIP Agent
(---------------) 3964 - Send Shutdown Signal to NUA
(---------------) 3964 - Terminate TCP/MRCPv2 Connection Agent
(---------------) 3964 - Terminate Media Processing Engine
(---------------) 752 - Process Control Message
(---------------) 5076 - Receive SIP Event [nua_r_shutdown] Status 200
Shutdown successful

Original issue reported on code.google.com by cpsoa...@gmail.com on 1 Jun 2009 at 2:27

GoogleCodeExporter commented 9 years ago
I tried the scenario you described on XP first, then started to think this 
somehow
could be related to 2003 only, but I've not managed to reproduce the freeze 
either on
XP or 2003.
Thus, I wonder whether the freeze is one to one reproducible on your end.
And as the next step, I'd suggest to put a breakpoint on mrcp_client_shutdown() 
call
and run the scenario again under Visual Studio debugger. As soon as debugger 
reaches
the breakpoint check number of threads running by that time (Debug -> Windows ->
Threads). Then step over the breakpoint and check running threads again.
Actually apr_thread_join() blocks executing context and releases it, when client
stack has been finally terminated.
I suspect that apr_thread_join() blocks infinitely in your case, however it 
shouldn't.

Original comment by achalo...@gmail.com on 15 Jun 2009 at 7:18

GoogleCodeExporter commented 9 years ago
  Hi,

  I analysed this a but deeper and it seems that it makes all the difference if I
create a bunch of sessions beforehand. In the destruction process I can see 
that you
have some code that works asynchronously and somewhat it doesn't complete the
termination loop (some state machine transition that is missing upon the finish 
of
all the task child terminations) as it leaves some child pending tasks yet to
terminate. I tried to modify the code on apt_task_child_terminate (line 364) as
follows and all worked fine, don't know if it has some side effect tough:

  1. Modified the apt_task_terminate second param to wait synchronously for child
termination.
  2. Commented out the pending_term so that at the end we have 0 child tasks pending.

        if(child_task) {
            if(apt_task_terminate(child_task,TRUE) == TRUE) {
                ; //task->pending_term++;
            }
        }

  I could live with this modification if it doesn't pose side-effects, please advice.
  Thanks in advance.

Regards.

Original comment by cpsoa...@gmail.com on 22 Jun 2009 at 5:25

GoogleCodeExporter commented 9 years ago
Hi,
I'm a bit anxious on how a bunch of session creation and destruction could alter
client stack termination. As I said, I tried to replicate the exact behavior 
with no
result.
Your modification should be safe, the only drawback is it slows down overall 
client
stack termination a bit.
Anyway, I'd prefer to understand what is going on first.
Try to apply the following one line change and see if it helps

Index: unimrcp/trunk/libs/apr-toolkit/src/apt_task.c
===================================================================
--- unimrcp/trunk/libs/apr-toolkit/src/apt_task.c   (revision 1001)
+++ unimrcp/trunk/libs/apr-toolkit/src/apt_task.c   (working copy)
@@ -413,5 +413,7 @@
    if(task->vtable.on_post_run) {
        task->vtable.on_post_run(task);
    }
+
+   apr_thread_exit(thread_handle,APR_SUCCESS);
    return NULL;
 }

Original comment by achalo...@gmail.com on 23 Jun 2009 at 5:31

GoogleCodeExporter commented 9 years ago
  Hi,

  Applying the patch you suggest the problem remains. After analysing a bit further
the code, I see CORE_TASK_MSG_TERMINATE_COMPLETE message to be sent only on
apt_task_child_terminate when all the tasks could successfuly be terminated on 
that
calling context and nowhere else. The program should receive as many
CORE_TASK_MSG_TERMINATE_COMPLETE messages as the tasks it tryed to stop in
apt_core_task_msg_process so that the running flag goes to FALSE and all is 
freed.
  By the way, in my case the task names that are listed to terminate upon the
CORE_TASK_MSG_TERMINATE_REQUEST received on apt_core_task_msg_process are: 
"SofiaSIP
Agent", "TCP/MRCPv2 Connection Agent" and "Media Processing Engine". The ones 
that
send the event CORE_TASK_MSG_TERMINATE_COMPLETE are: "MRCP Client" and "MRCP 
Client"
(strange, two tasks with the same name and no task from the previous list).
Nevertheless the reference counter task->pending_term remains with value 1, and
running flag remains TRUE.

  Regards.

Original comment by cpsoa...@gmail.com on 23 Jun 2009 at 11:00

GoogleCodeExporter commented 9 years ago
Hi,
Something really strange goes there. I'm just guessing what can be the reason.
Another option to try is to enable #define OWN_ALLOCATOR_PER_POOL

Index: unimrcp/trunk/libs/apr-toolkit/src/apt_pool.c
===================================================================
--- unimrcp/trunk/libs/apr-toolkit/src/apt_pool.c   (revision 1004)
+++ unimrcp/trunk/libs/apr-toolkit/src/apt_pool.c   (working copy)
@@ -16,7 +16,7 @@

 #include "apt_pool.h"

-//#define OWN_ALLOCATOR_PER_POOL
+#define OWN_ALLOCATOR_PER_POOL

Please give it a try.

Original comment by achalo...@gmail.com on 23 Jun 2009 at 11:45

GoogleCodeExporter commented 9 years ago
  Hi Arsen,

  Still the problem remains. For my case the patch I provided in one of the last
comments is good enough as I only create an unimrcp "application" in the 
beginning of
my application and end the unimrcp "application" at the end of my application.
Meanwhile, I do all sorts of ASR and TTS requests in the context of that unimrcp
application. I can live with this patch if during this "work" (consisting on a
chaotic set of TTS and ASR requests) it does not pose major impacts in terms of
performance.

  Regards.

Original comment by cpsoa...@gmail.com on 2 Jul 2009 at 1:06

GoogleCodeExporter commented 9 years ago
Hi cpsoares,
The patch affects only the termination process of client stack and has no 
impact 
while stack is up and running.
I'm doubtful about issue itself. Eventually I'll apply your patch to the tree, 
if
anything is found.

Original comment by achalo...@gmail.com on 2 Jul 2009 at 9:39

GoogleCodeExporter commented 9 years ago
Hi cpsoares,
The patch affects only the termination process of client stack and has no 
impact 
while stack is up and running.
I'm doubtful about issue itself. Eventually I'll apply your patch to the tree, 
if
anything is found.

Original comment by achalo...@gmail.com on 2 Jul 2009 at 9:39

GoogleCodeExporter commented 9 years ago
  Hi Arsen,

  As per your suggestion from Issue-29 I tried to reproduce this with the latest
patches from that issue and the problem remains. Please compare the traces for 
both
situations: without patch and with patch.

  Regards.

  Without Patch:
  --------------

(03 16:14:10.316) 180 - Create Application
(03 16:14:10.347) 180 - Register Application [SAUniMRCP]
(---------------) 180 - Start MRCP Client
(---------------) 5304 - Start SofiaSIP Agent
(---------------) 5304 - Start TCP/MRCPv2 Connection Agent
(---------------) 5304 - Start Media Processing Engine
(---------------) 1424 - Receive SIP Event [nua_r_set_params] Status 200 OK
(---------------) 5304 - MRCP Client Started
(---------------) 2492 - Create MRCP Handle 0x2858558 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x285a560 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x285c568 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x285e570 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x2860578 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x2862580 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x2864588 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x2866590 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x2868598 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x286a5a0 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x286c5a8 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x286e5b0 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28705b8 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28725c0 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28745c8 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28765d0 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28785d8 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x287a5e0 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x287c5e8 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x287e5f0 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28805f8 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x2882600 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x2884678 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28866f0 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x2888768 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x288a7e0 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x288c858 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x288e8d0 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x2890948 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28929c0 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x2894a38 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x2896ab0 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x2898b28 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x289aba0 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x289cc18 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x289ec90 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28a0d08 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28a2d80 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28a4df8 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28a6e70 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28a8ee8 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28aaf60 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28acfd8 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28af050 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28b10c8 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28b3140 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28b51b8 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28b7230 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28b92a8 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28bb320 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28bd398 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28bf410 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28c1488 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28c3500 [MRCPv2-Default]
(03 16:14:10.363) 2492 - Create MRCP Handle 0x28c5578 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28c75f0 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28c9668 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28cb6e0 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28cd758 [MRCPv2-Default]
(---------------) 2492 - Create MRCP Handle 0x28cf7d0 [MRCPv2-Default]
(03 16:14:23.582) 180 - Destroy MRCP Handle 0x2894a38
(---------------) 180 - Destroy MRCP Handle 0x2896ab0
(---------------) 180 - Destroy MRCP Handle 0x2898b28
(---------------) 180 - Destroy MRCP Handle 0x289aba0
(---------------) 180 - Destroy MRCP Handle 0x289cc18
(---------------) 180 - Destroy MRCP Handle 0x289ec90
(---------------) 180 - Destroy MRCP Handle 0x28a0d08
(---------------) 180 - Destroy MRCP Handle 0x28a2d80
(---------------) 180 - Destroy MRCP Handle 0x28a4df8
(---------------) 180 - Destroy MRCP Handle 0x28a6e70
(---------------) 180 - Destroy MRCP Handle 0x28a8ee8
(---------------) 180 - Destroy MRCP Handle 0x28aaf60
(---------------) 180 - Destroy MRCP Handle 0x28acfd8
(---------------) 180 - Destroy MRCP Handle 0x28af050
(---------------) 180 - Destroy MRCP Handle 0x28b10c8
(---------------) 180 - Destroy MRCP Handle 0x28b3140
(---------------) 180 - Destroy MRCP Handle 0x28b51b8
(---------------) 180 - Destroy MRCP Handle 0x28b7230
(---------------) 180 - Destroy MRCP Handle 0x28b92a8
(---------------) 180 - Destroy MRCP Handle 0x28bb320
(---------------) 180 - Destroy MRCP Handle 0x28bd398
(---------------) 180 - Destroy MRCP Handle 0x28bf410
(---------------) 180 - Destroy MRCP Handle 0x28c1488
(---------------) 180 - Destroy MRCP Handle 0x28c3500
(---------------) 180 - Destroy MRCP Handle 0x28c5578
(---------------) 180 - Destroy MRCP Handle 0x28c75f0
(---------------) 180 - Destroy MRCP Handle 0x28c9668
(---------------) 180 - Destroy MRCP Handle 0x28cb6e0
(---------------) 180 - Destroy MRCP Handle 0x28cd758
(---------------) 180 - Destroy MRCP Handle 0x28cf7d0
(---------------) 180 - Destroy MRCP Handle 0x2858558
(---------------) 180 - Destroy MRCP Handle 0x285a560
(---------------) 180 - Destroy MRCP Handle 0x285c568
(---------------) 180 - Destroy MRCP Handle 0x285e570
(---------------) 180 - Destroy MRCP Handle 0x2860578
(---------------) 180 - Destroy MRCP Handle 0x2862580
(---------------) 180 - Destroy MRCP Handle 0x2864588
(---------------) 180 - Destroy MRCP Handle 0x2866590
(---------------) 180 - Destroy MRCP Handle 0x2868598
(---------------) 180 - Destroy MRCP Handle 0x286a5a0
(---------------) 180 - Destroy MRCP Handle 0x286c5a8
(---------------) 180 - Destroy MRCP Handle 0x286e5b0
(---------------) 180 - Destroy MRCP Handle 0x28705b8
(03 16:14:23.598) 180 - Destroy MRCP Handle 0x28725c0
(---------------) 180 - Destroy MRCP Handle 0x28745c8
(---------------) 180 - Destroy MRCP Handle 0x28765d0
(---------------) 180 - Destroy MRCP Handle 0x28785d8
(---------------) 180 - Destroy MRCP Handle 0x287a5e0
(---------------) 180 - Destroy MRCP Handle 0x287c5e8
(---------------) 180 - Destroy MRCP Handle 0x287e5f0
(---------------) 180 - Destroy MRCP Handle 0x28805f8
(---------------) 180 - Destroy MRCP Handle 0x2882600
(---------------) 180 - Destroy MRCP Handle 0x2884678
(---------------) 180 - Destroy MRCP Handle 0x28866f0
(---------------) 180 - Destroy MRCP Handle 0x2888768
(---------------) 180 - Destroy MRCP Handle 0x288a7e0
(---------------) 180 - Destroy MRCP Handle 0x288c858
(---------------) 180 - Destroy MRCP Handle 0x288e8d0
(---------------) 180 - Destroy MRCP Handle 0x2890948
(---------------) 180 - Destroy MRCP Handle 0x28929c0
(---------------) 180 - Destroy Application
(---------------) 180 - Terminate MRCP Client
(---------------) 5304 - Terminate SofiaSIP Agent
(---------------) 5304 - Send Shutdown Signal to NUA
(---------------) 5304 - Terminate TCP/MRCPv2 Connection Agent
(---------------) 5304 - Terminate Media Processing Engine
(---------------) 3428 - Process Control Message
(---------------) 1424 - Receive SIP Event [nua_r_shutdown] Status 200 Shutdown
successful
(----STALLED----)

  With Patch:
  -----------

(03 16:16:16.069) 6004 - Create Application
(03 16:16:16.100) 6004 - Register Application [SAUniMRCP]
(---------------) 6004 - Start MRCP Client
(---------------) 1596 - Start SofiaSIP Agent
(---------------) 1596 - Start TCP/MRCPv2 Connection Agent
(---------------) 1596 - Start Media Processing Engine
(---------------) 1596 - MRCP Client Started
(---------------) 6084 - Receive SIP Event [nua_r_set_params] Status 200 OK
(03 16:16:16.131) 1760 - Create MRCP Handle 0x2858558 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x285a560 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x285c568 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x285e570 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x2860578 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x2862580 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x2864588 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x2866590 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x2868598 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x286a5a0 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x286c5a8 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x286e5b0 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28705b8 [MRCPv2-Default]
(03 16:16:16.147) 1760 - Create MRCP Handle 0x28725c0 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28745c8 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28765d0 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28785d8 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x287a5e0 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x287c5e8 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x287e5f0 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28805f8 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x2882600 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x2884678 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28866f0 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x2888768 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x288a7e0 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x288c858 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x288e8d0 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x2890948 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28929c0 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x2894a38 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x2896ab0 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x2898b28 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x289aba0 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x289cc18 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x289ec90 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28a0d08 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28a2d80 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28a4df8 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28a6e70 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28a8ee8 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28aaf60 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28acfd8 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28af050 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28b10c8 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28b3140 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28b51b8 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28b7230 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28b92a8 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28bb320 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28bd398 [MRCPv2-Default]
(03 16:16:16.162) 1760 - Create MRCP Handle 0x28bf410 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28c1488 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28c3500 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28c5578 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28c75f0 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28c9668 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28cb6e0 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28cd758 [MRCPv2-Default]
(---------------) 1760 - Create MRCP Handle 0x28cf7d0 [MRCPv2-Default]
(03 16:16:23.991) 6004 - Destroy MRCP Handle 0x2894a38
(---------------) 6004 - Destroy MRCP Handle 0x2896ab0
(---------------) 6004 - Destroy MRCP Handle 0x2898b28
(---------------) 6004 - Destroy MRCP Handle 0x289aba0
(---------------) 6004 - Destroy MRCP Handle 0x289cc18
(---------------) 6004 - Destroy MRCP Handle 0x289ec90
(---------------) 6004 - Destroy MRCP Handle 0x28a0d08
(---------------) 6004 - Destroy MRCP Handle 0x28a2d80
(---------------) 6004 - Destroy MRCP Handle 0x28a4df8
(---------------) 6004 - Destroy MRCP Handle 0x28a6e70
(---------------) 6004 - Destroy MRCP Handle 0x28a8ee8
(---------------) 6004 - Destroy MRCP Handle 0x28aaf60
(---------------) 6004 - Destroy MRCP Handle 0x28acfd8
(---------------) 6004 - Destroy MRCP Handle 0x28af050
(---------------) 6004 - Destroy MRCP Handle 0x28b10c8
(---------------) 6004 - Destroy MRCP Handle 0x28b3140
(---------------) 6004 - Destroy MRCP Handle 0x28b51b8
(---------------) 6004 - Destroy MRCP Handle 0x28b7230
(---------------) 6004 - Destroy MRCP Handle 0x28b92a8
(---------------) 6004 - Destroy MRCP Handle 0x28bb320
(---------------) 6004 - Destroy MRCP Handle 0x28bd398
(---------------) 6004 - Destroy MRCP Handle 0x28bf410
(---------------) 6004 - Destroy MRCP Handle 0x28c1488
(---------------) 6004 - Destroy MRCP Handle 0x28c3500
(---------------) 6004 - Destroy MRCP Handle 0x28c5578
(---------------) 6004 - Destroy MRCP Handle 0x28c75f0
(---------------) 6004 - Destroy MRCP Handle 0x28c9668
(---------------) 6004 - Destroy MRCP Handle 0x28cb6e0
(---------------) 6004 - Destroy MRCP Handle 0x28cd758
(---------------) 6004 - Destroy MRCP Handle 0x28cf7d0
(---------------) 6004 - Destroy MRCP Handle 0x2858558
(03 16:16:24.006) 6004 - Destroy MRCP Handle 0x285a560
(---------------) 6004 - Destroy MRCP Handle 0x285c568
(---------------) 6004 - Destroy MRCP Handle 0x285e570
(---------------) 6004 - Destroy MRCP Handle 0x2860578
(---------------) 6004 - Destroy MRCP Handle 0x2862580
(---------------) 6004 - Destroy MRCP Handle 0x2864588
(---------------) 6004 - Destroy MRCP Handle 0x2866590
(---------------) 6004 - Destroy MRCP Handle 0x2868598
(---------------) 6004 - Destroy MRCP Handle 0x286a5a0
(---------------) 6004 - Destroy MRCP Handle 0x286c5a8
(---------------) 6004 - Destroy MRCP Handle 0x286e5b0
(---------------) 6004 - Destroy MRCP Handle 0x28705b8
(---------------) 6004 - Destroy MRCP Handle 0x28725c0
(---------------) 6004 - Destroy MRCP Handle 0x28745c8
(---------------) 6004 - Destroy MRCP Handle 0x28765d0
(---------------) 6004 - Destroy MRCP Handle 0x28785d8
(---------------) 6004 - Destroy MRCP Handle 0x287a5e0
(---------------) 6004 - Destroy MRCP Handle 0x287c5e8
(---------------) 6004 - Destroy MRCP Handle 0x287e5f0
(---------------) 6004 - Destroy MRCP Handle 0x28805f8
(---------------) 6004 - Destroy MRCP Handle 0x2882600
(---------------) 6004 - Destroy MRCP Handle 0x2884678
(---------------) 6004 - Destroy MRCP Handle 0x28866f0
(---------------) 6004 - Destroy MRCP Handle 0x2888768
(---------------) 6004 - Destroy MRCP Handle 0x288a7e0
(---------------) 6004 - Destroy MRCP Handle 0x288c858
(---------------) 6004 - Destroy MRCP Handle 0x288e8d0
(---------------) 6004 - Destroy MRCP Handle 0x2890948
(---------------) 6004 - Destroy MRCP Handle 0x28929c0
(---------------) 6004 - Destroy Application
(---------------) 6004 - Terminate MRCP Client
(---------------) 1596 - Terminate SofiaSIP Agent
(---------------) 1596 - Send Shutdown Signal to NUA
(---------------) 6084 - Receive SIP Event [nua_r_shutdown] Status 200 Shutdown
successful
(---------------) 1596 - Terminate TCP/MRCPv2 Connection Agent
(---------------) 4064 - Process Control Message
(---------------) 1596 - Terminate Media Processing Engine
(---------------) 1596 - MRCP Client Terminated

Original comment by cpsoa...@gmail.com on 3 Jul 2009 at 4:21

GoogleCodeExporter commented 9 years ago
  Hi Arsen,

  Just to clarify, when I say with and without patch, this patch is the one I
discussed a few messages ago. These tests however were both done with your 
patch for
issue-28 applied. :-D Sorry for the confusion.

  Regards.

Original comment by cpsoa...@gmail.com on 3 Jul 2009 at 4:23

GoogleCodeExporter commented 9 years ago
Hi cpsoares,
It seems I understand what you meant. I hoped patch for issue-29 could help, 
but it
didn't...

You already described the scenario and I tried to replicate it on my side. Now
I'm thinking whether it's possible to provide an exact and minimal source code 
of
that application to me without proprietary stuff. Hopefully this will help 
finally
pinpoint the problem.

Original comment by achalo...@gmail.com on 6 Jul 2009 at 11:50

GoogleCodeExporter commented 9 years ago
  Hi Arsen,

  Just made a simple brute-force application re-incarnated over demorecog project.
Just overwrite some files and there you go. I send the readme and source on
attachment. Please don't look too much on the code quality because it was only 
made
to compile and link and last but not the least to illustrate the problem.
  Please tell me if you need anything else.

  Regards.

Original comment by cpsoa...@gmail.com on 7 Jul 2009 at 2:00

Attachments:

GoogleCodeExporter commented 9 years ago
Hi cpsoares,
I expected that application should generate a bulk of sessions and destroy them
immediately, shouldn't it?

Currently it initializes client stack on startup
Create Application
Register Application [SAUniMRCP]
Start MRCP Client
MRCP Client Started

and as soon as I press ENTER, application is terminated
Destroy Application
Terminate MRCP Client
MRCP Client Terminated

Is this enough to reproduce that issue? 

Original comment by achalo...@gmail.com on 8 Jul 2009 at 5:23

GoogleCodeExporter commented 9 years ago
  Hi Arsen,

  As for the sessions, I tried with no session creation and I could also reproduce
the problem, so I didn't bother to make the session logic in the sample program 
I
gave you.
  I can always reproduce the problem here on my machine that is a XP Professional 32
bit OS (with Intel Dual Core 6400@ 2.13 GHz CPU), also on a Windows 2003 Server
machine (which is also uses a Dual Core Intel CPU) I use for stress testing.
  Maybe this is some kind of race condition. Strange thing is that it always happens
here.

  Regards.

Original comment by cpsoa...@gmail.com on 8 Jul 2009 at 8:55

GoogleCodeExporter commented 9 years ago
Hi cpsoares,
This seemed to be really strange, but hopefully I found out the reason.
Your demo application is definitely missing calls to apr_initialize() and
apr_terminate().
apr_initialize() must be very first call in the applications, which are using 
UniMRCP
and/or APR libraries.
I intentionally expose these functions out of client stack, because there are 
(could
be) applications, which have been already using APR.
More over, it's not necessary to call WSAStartup() and WSACleanup(), as
apr_initalize() and apr_terminate() do it internally.
Give it a try and let me know the results.

Original comment by achalo...@gmail.com on 8 Jul 2009 at 11:08

GoogleCodeExporter commented 9 years ago
  Hi Arsen,

  Looking at my application code on which the MRCP integration resides on a DLL, I
have apr_initialize and friends on the DllMain respectively on the process 
attach and
detach sections. So the problem may not still be in there. Nevertheless, I'll 
try
that in a few moments. I'll keep you posted.

  Regards.

Original comment by cpsoa...@gmail.com on 8 Jul 2009 at 11:41

GoogleCodeExporter commented 9 years ago
  OK, finish testing on the sample application with the apr_initialize and friends
and the same result. It stays stuck at the message "Terminate Media Processing
Engine". Are you using dual core CPUs? There are some races that can be better
explored when we have true multiprocessing.

  I'll post the output:

Create Application
Register Application [SAUniMRCP]
Start MRCP Client
Start SofiaSIP Agent
Start TCP/MRCPv2 Connection Agent
Start Media Processing Engine
Adding nameserver: 10.254.0.121
Adding nameserver: 10.254.0.122
nta_agent: received garbage from udp/10.10.0.103:13565/sip
MRCP Client Started
Receive SIP Event [nua_r_set_params] Status 200 OK
Destroy Application
Terminate MRCP Client
Terminate SofiaSIP Agent
Send Shutdown Signal to NUA
Terminate TCP/MRCPv2 Connection Agent
Receive SIP Event [nua_r_shutdown] Status 200 Shutdown successful
Process Control Message
Terminate Media Processing Engine

Original comment by cpsoa...@gmail.com on 8 Jul 2009 at 2:31

Attachments:

GoogleCodeExporter commented 9 years ago
Well, I've got it, since I started to use your unimrcpclient.xml
With this config even my demo unimrcpclient application freezes on exit.
I don't know, what is going on exactly, but  ... more to come

BTW, my win dev environment is:
XP SP2 Core2Duo 32bit
Vista SP1 Core2Dua 32 bit
and recently I've installed 2003 on an old P4

Original comment by achalo...@gmail.com on 8 Jul 2009 at 2:57

GoogleCodeExporter commented 9 years ago
Network client/server stacks generated double TERMINATE_COMPLETE event, while 
mpf
engine generated no TERMINATE_COMPLETE event at all.
This kept pending_term counter balanced, that's why it "worked" with the default
config, however caused problems in case there was no RTSP agent in config.
Wow...

Original comment by achalo...@gmail.com on 8 Jul 2009 at 4:40

GoogleCodeExporter commented 9 years ago
Hi Carlos,
I assume, this issue has indeed been fixed.
Have you verified it?

Original comment by achalo...@gmail.com on 5 Oct 2009 at 4:19

GoogleCodeExporter commented 9 years ago
Yes, it was verified and working 100% on my side. Thanks once again Arsen.

Original comment by cpsoa...@gmail.com on 6 Oct 2009 at 9:35

GoogleCodeExporter commented 9 years ago
Thanks

Original comment by achalo...@gmail.com on 6 Oct 2009 at 10:05