Skip to content

utf8::length() bad #2280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
p5pRT opened this issue Jul 30, 2000 · 4 comments
Closed

utf8::length() bad #2280

p5pRT opened this issue Jul 30, 2000 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 30, 2000

Migrated from rt.perl.org#3598 (status was 'resolved')

Searchable as RT3598$

@p5pRT
Copy link
Author

p5pRT commented Jul 30, 2000

From [email protected]

Created by [email protected]

Hi,

  % perl -mutf8 -e "print utf8​::length('a')"

causes my cpu to peg, and memory to grow until I break out of it.

I tried running it in gdb, got a segfault report immediately, but the
thing kept running (and sucking memory) until I broke out of it​:

  (gdb) run -mutf8 -e "print utf8​::length('a')"
  Starting program​: /usr/src/perl-5.6.0/perl -mutf8 -e "print utf8​::length('a')"
  Segmentation fault (core dumped)

--- several seconds pass, then I interrupt it ---

  Program received signal SIGINT, Interrupt.
  0x8091349 in Perl_hv_fetch (hv=0x80f08e0, key=0xbffff0e4 "utf8​::", klen=6,
  lval=1) at hv.c​:181
  181 PERL_HASH(hash, key, klen);
  (gdb) where
  #0 0x8091349 in Perl_hv_fetch (hv=0x80f08e0, key=0xbffff0e4 "utf8​::", klen=6,
  lval=1) at hv.c​:181
  #1 0x805fe73 in Perl_gv_fetchpv (nambeg=0x80fcb10 "utf8​::length", add=1,
  sv_type=12) at gv.c​:550
  #2 0x80a11e3 in Perl_sv_2cv (sv=0x80fb010, st=0xbffff224, gvp=0xbffff228,
  lref=1) at sv.c​:4981
  #3 0x80a3fde in Perl_pp_rv2cv () at pp.c​:379
  #4 0x80949ed in Perl_runops_standard () at run.c​:27
  #5 0x805bd4e in S_run_body (oldscope=1) at perl.c​:1401
  #6 0x805bad8 in perl_run (my_perl=0x80f0858) at perl.c​:1325
  #7 0x8059903 in main (argc=4, argv=0xbffff354, env=0xbffff368)
  at perlmain.c​:52

Even though I have my coredumplimit set to zero, when running this from
within gdb, it does dump a small (360k) core file. On a whim, I ran

  jfriedl@​fummy> gdb /usr/src/perl-5.6.0/perl core
  GNU gdb 4.18
  Copyright 1998 Free Software Foundation, Inc.
  This GDB was configured as "i386-mandrake-linux"...

  warning​: core file may not match specified executable file.
  Core was generated by `perl -w test -d /etc/profile.d'.
  Program terminated with signal 11, Segmentation fault.
  Reading symbols from /lib/libnsl.so.1...done.
  Reading symbols from /lib/libdb.so.3...done.
  Reading symbols from /usr/lib/libgdbm.so.2...done.
  Reading symbols from /lib/libdl.so.2...done.
  Reading symbols from /lib/libm.so.6...done.
  Reading symbols from /lib/libc.so.6...done.
  Reading symbols from /lib/libcrypt.so.1...done.
  Reading symbols from /lib/ld-linux.so.2...done.
  #0 0x400fd1f4 in memmove () from /lib/libc.so.6
  (gdb) where
  #0 0x400fd1f4 in memmove () from /lib/libc.so.6
  #1 0x80faf7c in ?? ()
  Cannot access memory at address 0x1.

Which seems odd, to say the least.

  Jeffrey

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl v5.6.0:

Configured by jfriedl at Sat Jul 29 20:09:33 PDT 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.2.15, archname=i686-linux
    uname='linux fummy.dsl.yahoo.com 2.2.16 #6 smp sun jul 23 11:26:16 pdt 2000 i686 unknown '
    config_args='-ds -e -A optimize=-g'
    hint=previous, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-O2 -g', gccversion=pgcc-2.91.66 19990314 (egcs-1.1.2 release)
    cppflags='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    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, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=/lib/libc-2.1.1.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.6.0:
    /home/jfriedl/lib/perl
    /home/jfriedl/lib/perl/yahoo
    /usr/local/lib/perl5/5.6.0/i686-linux
    /usr/local/lib/perl5/5.6.0
    /usr/local/lib/perl5/site_perl/5.6.0/i686-linux
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.6.0:
    HOME=/home/jfriedl
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/usr/local/pgsql/lib:/home/jfriedl/src/rvplayer5.0
    LOGDIR (unset)
    PATH=/home/jfriedl/bin:/home/jfriedl/common/bin:/usr/local/gcc-2.95.2/bin:.:/usr/local/pgsql/bin:/usr/local/bin:/usr/X11R6/bin:/bin:/usr/bin:/usr/sbin:/sbin:/home/jfriedl/src/rvplayer5.0
    PERLLIB=/home/jfriedl/lib/perl:/home/jfriedl/lib/perl/yahoo
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh


@p5pRT
Copy link
Author

p5pRT commented Jul 31, 2000

From [Unknown Contact. See original ticket]

Jeffrey Friedl (lists.p5p)​:

% perl -mutf8 -e "print utf8​::length('a')"

causes my cpu to peg, and memory to grow until I break out of it.

Oh, *swear*. I know why this is happening, and I'll have a look at it
today if possible.

@p5pRT
Copy link
Author

p5pRT commented Jul 31, 2000

From [Unknown Contact. See original ticket]

Simon Cozens (lists.p5p)​:

Jeffrey Friedl (lists.p5p)​:

% perl -mutf8 -e "print utf8​::length('a')"

causes my cpu to peg, and memory to grow until I break out of it.

Oh, *swear*. I know why this is happening, and I'll have a look at it
today if possible.

Hm, this was more fundamental than I thought. Why do you think you
should be able to call utf8​::length? utf8 is a pragma, not a module
which replaces Perl's builtins.

Nevertheless, recursive AUTOLOADs are certainly bad.

Inline Patch
--- lib/utf8.pm~        Tue Aug  1 15:46:44 2000
+++ lib/utf8.pm Tue Aug  1 15:53:16 2000
@@ -13,7 +13,8 @@

 sub AUTOLOAD {
     require "utf8_heavy.pl";
-    goto &$AUTOLOAD;
+    goto &$AUTOLOAD if defined &$AUTOLOAD;
+    Carp::croak("Undefined subroutine $AUTOLOAD called");
 }

 1;

@p5pRT
Copy link
Author

p5pRT commented Aug 10, 2000

From @jhi

Nevertheless, recursive AUTOLOADs are certainly bad.

--- lib/utf8.pm~ Tue Aug 1 15​:46​:44 2000
+++ lib/utf8.pm Tue Aug 1 15​:53​:16 2000
@​@​ -13,7 +13,8 @​@​

sub AUTOLOAD {
require "utf8_heavy.pl";
- goto &$AUTOLOAD;
+ goto &$AUTOLOAD if defined &$AUTOLOAD;
+ Carp​::croak("Undefined subroutine $AUTOLOAD called");
}

1;

Applied, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant