unispeech / unimrcp

Open source cross-platform implementation of MRCP protocol
http://www.unimrcp.org
Apache License 2.0
374 stars 165 forks source link

Connector 1.0.0 crashes Asterisk 1.8 and 11 on Ubuntu when used against Lumenvox. #156

Closed achaloyan closed 9 years ago

achaloyan commented 9 years ago

Originally reported on Google Code with ID 157

What steps will reproduce the problem?
1. Install Asterisk 11.3.0 from source or 1.8.10.1~dfsg-1ubuntu1 from packages on Ubuntu
12.04
2. Install UniMRCP Asterisk connector 1.0.0
3. Invoce SynthAndRecog using SSML TTS and a GRXML inline grammar

Asterisk simply segfaults and shuts down.
I am still leaning on me doing something wrong, but the setup is as simple as it gets.

Reported by luca.pradovera on 2013-04-15 14:27:06

achaloyan commented 9 years ago
To elaborate further, the issue is only present when issuing commands over AMI.

The following is the AMI version of a working dialplan example and crashes Asterisk:

Action: agi
ActionID: 8461ac3f-e2cb-4fc8-8699-29b8d0e038f9
Channel: SIP/usera-0000000c
Command: EXEC SynthAndRecog "<?xml version=\\\"1.0\\\"?><speak version=\\\"1.0\\\"
xmlns=\\\"http://www.w3.org/2001/10/synthesis\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\"
xsi:schemaLocation=\\\"http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd\\\"
xml:lang=\\\"en-GB\\\">Please pick a color: red <break/> green <break/> or blue </speak>"
"<?xml version=\\\"1.0\\\"?><grammar xmlns=\\\"http://www.w3.org/2001/06/grammar\\\"
xml:lang=\\\"en-GB\\\" version=\\\"1.0\\\" mode=\\\"voice\\\" tag-format=\\\"semantics/1.0-literals\\\"
root=\\\"color\\\"><rule id=\\\"color\\\"><one-of><item>red</item><item>green</item><item>blue</item></one-of></rule></grammar>"
"t=5000&b=1&ct=0.7&spl=en-GB"
CommandID: 045d84fc-3750-412b-8db0-e3e0093ee706

Reported by luca.pradovera on 2013-04-15 16:33:53

achaloyan commented 9 years ago
The same command:
EXEC SynthAndRecog "<?xml version=\\\"1.0\\\"?><speak version=\\\"1.0\\\" xmlns=\\\"http://www.w3.org/2001/10/synthesis\\\"
xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xsi:schemaLocation=\\\"http://www.w3.org/2001/10/synthesis
http://www.w3.org/TR/speech-synthesis/synthesis.xsd\\\" xml:lang=\\\"en-GB\\\">Please
pick a color: red <break/> green <break/> or blue </speak>","<?xml version=\\\"1.0\\\"?><grammar
xmlns=\\\"http://www.w3.org/2001/06/grammar\\\" xml:lang=\\\"en-GB\\\" version=\\\"1.0\\\"
mode=\\\"voice\\\" tag-format=\\\"semantics/1.0-literals\\\" root=\\\"color\\\"><rule
id=\\\"color\\\"><one-of><item>red</item><item>green</item><item>blue</item></one-of></rule></grammar>","t=5000&b=1&ct=0.7&spl=en-GB"

works over FastAGI without any particular issue.
The commas separating the arguments instead of spaces are a protocol difference and
intended.

Reported by luca.pradovera on 2013-04-15 20:08:44

achaloyan commented 9 years ago
The question is how SynthAndRecog eventually is getting executed, or more specifically,
how input arguments are passed through AMI, AGI to the application.

The following AGI EXEC command invoked via an AMI action request does work.

T 127.0.0.1:46187 -> 127.0.0.1:5038 [AP]
  Action: AGI..Command: EXEC SynthAndRecog "<?xml version=\'1.0\'?><speak version=\'1.0\'
xmlns=\'http://www.w3.org/2001/10/synthesis\' xmlns:xsi=\'http://www.w3.org/2001/XMLSchema-instance\'
xsi:schemaLoc
  ation=\'http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd\'
xml:lang=\'en-US\'>Please pick a color: red <break/> green <break/> or blue </speak>","<?xml
version=\'1.
  0\'?><grammar xmlns=\'http://www.w3.org/2001/06/grammar\' xml:lang=\'en-US\' version=\'1.0\'
mode=\'voice\' tag-format=\'semantics/1.0-literals\' root=\'color\'><rule id=\'color\'><one-of><item>red</item
  ><item>green</item><item>blue</item></one-of></rule></grammar>","t=5000&b=1&ct=0.7&spl=en-US"..CommandID:
Command-2..Channel: SIP/511-00000013..ActionID: testdomain.com-12923-00000003....

Pay attention to the delimiters used in the example above. 

Meantime, I wanted to reproduce the crash but was not able to do so. It should be just
a matter of arguments passed to the application in an unexpected format. If you could
attach the corresponding Asterisk debug logs, that would help. Thanks.

Reported by achaloyan on 2013-04-16 01:44:20

achaloyan commented 9 years ago
Hello,
to follow up, changing the escaping on the command and using commas works correctly.
The wrong argument separator still segfaults Asterisk but I think this can be downgraded
to a minor issue.

Reported by luca.pradovera on 2013-04-16 14:30:51

achaloyan commented 9 years ago
Hello Luca,

FYI, Asterisk didn't segfault on my test machine running CentOS even if the wrong separator
was used. Though, it could be just by luck since there was a NULL pointer reference.

Anyway, in r1960, I enhanced the code to test input arguments more carefully to prevent
a possible segfault of Asterisk which may caused by a wrong argument separator, or
a missing argument, etc.

Reported by achaloyan on 2013-04-18 01:57:20