Subject: | Error (wide character) and warning (use of uninitialized value) with DBIC_TRACE=1 |
There is and error and some warnings (probably 2 separate things) when
running under these conditions:
- standalone server
- DBIC_TRACE=1 tracing
- "warnings: 1" in environments/development.yml
- i update some data in DB with unicode character (in my case euro sign)
- STDERR is printed on console
This has similar conditions as with bugreport [rt.cpan.org #62747] but
different problems. The problem appears when I update some unicode data
in DB and then is called "template 'name' { some_data };" as a last
statement in my route handler. 4 warnings get printed to the console:
Use of uninitialized value in concatenation (.) or string at
/home/ico/perl5/perlbrew/perls/perl-5.12.2/lib/site_perl/5.12.2/Dancer/Handler.pm
line 131.
Use of uninitialized value in hash element at
/home/ico/perl5/perlbrew/perls/perl-5.12.2/lib/site_perl/5.12.2/HTTP/Server/Simple/PSGI.pm
line 120.
Use of uninitialized value in concatenation (.) or string at
/home/ico/perl5/perlbrew/perls/perl-5.12.2/lib/site_perl/5.12.2/HTTP/Server/Simple/PSGI.pm
line 122.
Use of uninitialized value $message in concatenation (.) or string at
/home/ico/perl5/perlbrew/perls/perl-5.12.2/lib/site_perl/5.12.2/HTTP/Server/Simple/PSGI.pm
line 122.
At the same time there is an error report to the browser (shortened here):
runtime error
Warning caught during route execution: Wide character in print at
/home/ico/perl5/perlbrew/perls/perl-5.12.2/lib/5.12.2/i686-linux/IO/Handle.pm
line 406.
403 sub print {
404 @_ or croak 'usage: $io->print(ARGS)';
405 my $this = shift;
406 print $this @_;
407 }
408
409 sub printf {
When doesn't get the error nor warnings produced:
- the template call without data (e.g. "template 'name';")
- or updating non-unicode data to the DB
- or updating unicode data the same as was before - thus DBIx::Class
layer detects that nothing needs to be updated and no SQL statement
containing unicode characters gets printed to console
- or not using DBIC_TRACE=1 (no unicode debug output to console)
- or redirecting STDERR to file by running application like this
`DBIC_TRACE=1 ./app.pl > logfile.log 2>&1`
- or setting "warnings: 0" in environments/development.yml - then it is
reported as another bug [rt.cpan.org #62747]
From this my understanding is that problem is when unicode data gets
printed to STDERR.
--------
Another problem is in my opinion the warnings printed to console. When
printing a dump of $response in .../Dancer/Handler.pm on line 130 (just
before a line producing warinig) there is no status set in HTTP headers.
You can see that there is even no code set in <title>Error </title>
(shortened here):
UPDATE `group` SET `name` = ? WHERE ( `id` = ? ): 'Switch -2,97 €', '17'
$VAR1 = bless( {
'pass' => 0,
'headers' => bless( {
'x-powered-by' => 'Perl Dancer
1.1999_02',
'content-type' => 'text/html;
charset=UTF-8'
}, 'HTTP::Headers' ),
'status' => undef,
'content' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Error </title>
<link rel="stylesheet" href="/css/error.css" />
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Error </h1>
<div id="content">
<h2>runtime error</h2><pre class="error">Warning caught during route
execution: Wide character in print at
/home/ico/perl5/perlbrew/perls/perl-5.12.2/lib/5.12.2/i686-linux/IO/Handle.pm
line 406.
My connection to DB and all data is in UTF8. Connection to DB is via
DBIx::Class like this:
$::schema = App::DB->connect(
"DBI:mysql:database=$DB", $login, $pass,
{
on_connect_do => "set names utf8;",
mysql_enable_utf8 => 1,
}
);
Settings in config.yml:
log: "core"
layout: "main"
logger: "file"
charset: "UTF-8"
template: template_toolkit
engines:
template_toolkit:
start_tag: '[%'
stop_tag: '%]'
EVAL_PERL: "1"
UNICODE: "1"
ENCODING: "utf8"
My envoronment:
Dancer:
$ perl -MDancer -e 'print $Dancer::VERSION;'
1.1999_02
perl:
$ perl -V
Summary of my perl5 (revision 5 version 12 subversion 2) configuration:
Platform:
osname=linux, osvers=2.6.34-i1-smp, archname=i686-linux
uname='linux puding 2.6.34-i1-smp #1 smp thu may 27 16:30:13 cest
2010 i686 intel(r) core(tm) i5 cpu m 520 @ 2.40ghz genuineintel gnulinux '
config_args='-de -Dprefix=/home/ico/perl5/perlbrew/perls/perl-5.12.2'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include'
ccversion='', gccversion='4.4.4', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.11.1.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.11.1'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib
-fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF
Built under linux
Compiled at Nov 4 2010 22:35:11
%ENV:
PERLBREW_PATH="/home/ico/perl5/perlbrew/bin:/home/ico/perl5/perlbrew/perls/perl-5.12.2/bin"
PERLBREW_PERL="perl-5.12.2"
PERLBREW_ROOT="/home/ico/perl5/perlbrew"
PERLBREW_VERSION="0.12"
@INC:
/home/ico/perl5/perlbrew/perls/perl-5.12.2/lib/site_perl/5.12.2/i686-linux
/home/ico/perl5/perlbrew/perls/perl-5.12.2/lib/site_perl/5.12.2
/home/ico/perl5/perlbrew/perls/perl-5.12.2/lib/5.12.2/i686-linux
/home/ico/perl5/perlbrew/perls/perl-5.12.2/lib/5.12.2
.
OS:
slackware 13.1
$ uname -a
Linux puding 2.6.34-i1-smp #1 SMP Thu May 27 16:30:13 CEST 2010 i686
Intel(R) Core(TM) i5 CPU M 520 @ 2.40GHz GenuineIntel GNU/Linux
DB:
$ mysql --version
mysql Ver 14.14 Distrib 5.1.46, for slackware-linux-gnu (i486) using
readline 5.1