[SRILM User List] lattice-tool -timeout bugfix [was: need help with SRILM installation]
Andreas Stolcke
stolcke at icsi.berkeley.edu
Wed Jun 13 11:33:38 PDT 2012
On 6/9/2012 3:46 AM, NEETI SONTH wrote:
>
>
>> Hi.
>
> When I run the command 'lattice-tool -max-time 4 -write-ngrams
> <filename> -in-lattice-list <filename2>'
> the command limits the maximum time of operation for just the first
> lattice file in the list of lattice files. For remaining
> lattice-files, it doesnt limit the time of operation. The command says
> "LIMITS THE MAXIMUM TIME OF OPERATION PER LATTICE" ... So why isnt it
> doing so???
>
> thanks.
> Neeti Sonth
>
It seems that in Linux and compatible systems, unlike in Solaris, where
the code was originally developed, the SIGALRM handler needs to use
sigsetjmp/siglongjmp() instead of just plain setjmp/longjmp, or else
subsequent alarms won't invoke the handler due to signal mask
modification. The effect was that lattice-tool -timeout would work
only for the first lattice triggering the timeout on Linux and Cygwin
systems.
The attached patch should fix the problem.
Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.speech.sri.com/pipermail/srilm-user/attachments/20120613/1565d24b/attachment.html>
-------------- next part --------------
Index: lattice-tool.cc
===================================================================
RCS file: /home/srilm/CVS/srilm/lattice/src/lattice-tool.cc,v
retrieving revision 1.156
diff -c -r1.156 lattice-tool.cc
*** lattice-tool.cc 21 Apr 2011 06:12:49 -0000 1.156
--- lattice-tool.cc 13 Jun 2012 18:17:25 -0000
***************
*** 376,386 ****
#endif
typedef void (*sighandler_t)(_sigargs);
! static jmp_buf thisContext;
void catchAlarm(int signal)
{
! longjmp(thisContext, 1);
}
#endif /* !NO_TIMEOUT */
--- 376,386 ----
#endif
typedef void (*sighandler_t)(_sigargs);
! static sigjmp_buf thisContext;
void catchAlarm(int signal)
{
! siglongjmp(thisContext, 1);
}
#endif /* !NO_TIMEOUT */
***************
*** 484,490 ****
#ifndef NO_TIMEOUT
if (maxTime) {
alarm(maxTime);
! if (setjmp(thisContext)) {
cerr << "WARNING: processing lattice " << inLat
<< " aborted after " << maxTime << " seconds\n";
return;
--- 484,490 ----
#ifndef NO_TIMEOUT
if (maxTime) {
alarm(maxTime);
! if (sigsetjmp(thisContext, 1)) {
cerr << "WARNING: processing lattice " << inLat
<< " aborted after " << maxTime << " seconds\n";
return;
More information about the SRILM-User
mailing list