Skip Menu |

This queue is for tickets about the Template-Toolkit CPAN distribution.

Report information
The Basics
Id: 54528
Status: resolved
Priority: 0/
Queue: Template-Toolkit

People
Owner: Nobody in particular
Requestors: kavi [...] saralweb.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: WHILE_MAX setting does not seem to work
Date: Thu, 11 Feb 2010 13:58:04 -0800
To: bug-Template-Toolkit [...] rt.cpan.org
From: kavi <kavi [...] saralweb.com>
platform (uname -a ) ------------------------------------ Linux kavi-hp 2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:05:01 UTC 2009 x86_64 GNU/Linux template toolkit version --------------------------------------- tpage 2.7 (Template Toolkit version 2.22) tpage command --------------------------- tpage --load_perl testfile contents of testfile ------------------------------- [% USE Template.Directive %] [% Template.Directive.WHILE_MAX = 1000000 %] [% counter = 0 %] [% WHILE counter < 10000 %] [% counter = counter + 1 %] counter = [% counter %] [% END %] error message / crash --------------------------------------- undef error - WHILE loop terminated (> 1000 iterations) Further narrative ----------------------------- I can't get WHILE_MAX setting to work. My actual code is a perl module which calls process() on a template object created via new() method on Template. In my code I am doing : use Template::Directive; $Template::Directive::WHILE_MAX=1000000 but that code also crashes with the same message. I have managed to reproduce the probem with a simple template fragment pasted above. You can check the value of WHILE_MAX also as below (you must comment out the while loop or else it crashes anyway). [% USE Template.Directive %] [% Template.Directive.WHILE_MAX = 1000000 %] while max is [% Template.Directive.WHILE_MAX %] [% counter = 0 %] [%# WHILE counter < 10000 %] [% counter = counter + 1 %] counter = [% counter %] [%# END %] I have the same problem whether Stash is enabled or not... thx - kavi Show quoted text
_____________________________________________________________________ List your Business on http://www.saralweb.com/findex.pl for FREE and generate sales inquiries.
Subject: Re: [rt.cpan.org #54528] AutoReply: WHILE_MAX setting does not seem to work
Date: Thu, 11 Feb 2010 14:00:46 -0800
To: bug-Template-Toolkit [...] rt.cpan.org
From: kavi <kavi [...] saralweb.com>
following up with additional (missing) information, the perl configuration detail perl -V Summary of my perl5 (revision 5 version 10 subversion 0) configuration: Platform: osname=linux, osvers=2.6.31-14-generic, archname=x86_64-linux uname='linux kavi-hp 2.6.31-14-generic #48-ubuntu smp fri oct 16 14:05:01 utc 2009 x86_64 gnulinux ' config_args='de' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fPIC -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-fPIC' ccversion='', gccversion='4.4.1', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64 libs=-ldb -ldl -lm -lc -lcrypt perllibs=-ldl -lm -lc -lcrypt libc=/lib/libc-2.10.1.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.10.1' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP USE_64_BIT_ALL USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO Built under linux Compiled at Feb 5 2010 22:13:22 @INC: /usr/local/lib/perl5/5.10.0/x86_64-linux /usr/local/lib/perl5/5.10.0 /usr/local/lib/perl5/site_perl/5.10.0/x86_64-linux /usr/local/lib/perl5/site_perl/5.10.0 Show quoted text
_____________________________________________________________________ List your Business on http://www.saralweb.com/findex.pl for FREE and generate sales inquiries.
From: felix.ostmann [...] gmail.com
The problem is, that most users use template-caches. So changing this value will only help, when you remove all cache-files. A complete dynamic value is not possible. Additional the logic is wrong: In my tests, a loop with 1000 iterations throw this error. After reading the code and testing, the error will be thrown after 998 iterations! The problem is the order of the decrement and the loop-expression in the first (a 1 iteration-loop, will decrement 2 times the counter) and additional the check of true is wrong, is must be checked if counter >= 0. I changed the logic in Template::Directive in row ~565 from the following code: # WHILE do { my \$_tt_failsafe = $WHILE_MAX; $label: while (--\$_tt_failsafe && ($expr)) { $block } die "WHILE loop terminated (> $WHILE_MAX iterations)\\n" unless \$_tt_failsafe; }; to this code: # WHILE do { my \$_tt_failsafe = $WHILE_MAX; $label: while (($expr) && --\$_tt_failsafe >= 0) { $block } die "WHILE loop terminated (> $WHILE_MAX iterations)\\n" if \$_tt_failsafe < 0; };
Ticket migrated to github as https://github.com/abw/Template2/issues/149