Skip to content
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

Too late warning not given for CHECK block in INIT block #6990

Open
p5pRT opened this issue Dec 17, 2003 · 6 comments
Open

Too late warning not given for CHECK block in INIT block #6990

p5pRT opened this issue Dec 17, 2003 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Dec 17, 2003

Migrated from rt.perl.org#24684 (status was 'open')

Searchable as RT24684$

@p5pRT
Copy link
Author

p5pRT commented Dec 17, 2003

From @ysth

Created by @ysth

This code should give a "Too late to run CHECK block" warning but
doesn't​:

perl -we'INIT { eval "CHECK {print qq​:in check in init\n​:}" }'

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.8.2:

Configured by Gerrit at Fri Nov  7 12:03:56     2003.

Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
  Platform:
    osname=cygwin, osvers=1.5.5(0.9432), archname=cygwin-thread-multi-64int
    uname='cygwin_nt-5.0 troubardix 1.5.5(0.9432) 2003-09-20 16:31 i686 unknown unknown cygwin '
    config_args='-de -Dmksymlinks -Duse64bitint -Dusethreads -Doptimize=-O2 -Dman3ext=3pm'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=undef
    usemymalloc=y, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing',
    optimize='-O2',
    cppflags='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing'
    ccversion='', gccversion='3.3.1 (cygming special)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='ld2', ldflags =' -s -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib /lib
    libs=-lgdbm -ldb -lcrypt -lgdbm_compat
    perllibs=-lcrypt -lgdbm_compat
    libc=/usr/lib/libc.a, so=dll, useshrplib=true, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' -s'
    cccdlflags=' ', lddlflags=' -s -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.8.2:
    /usr/lib/perl5/5.8.2/cygwin-thread-multi-64int
    /usr/lib/perl5/5.8.2
    /usr/lib/perl5/site_perl/5.8.2/cygwin-thread-multi-64int
    /usr/lib/perl5/site_perl/5.8.2
    /usr/lib/perl5/site_perl
    .


Environment for perl v5.8.2:
    CYGWIN=tty ntsec title
    HOME=/home/sthoenna
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/Program Files/Common Files/Adaptec Shared/System:/cygdrive/c/Program Files/Rational/common
    PERL_BADLANG (unset)
    SHELL (unset)

@p5pRT
Copy link
Author

p5pRT commented Dec 18, 2011

From @wolfsage

Thanks for the report.

This is because when nothing is actually happening in the main scope of
the program it's treated as an OP_STUB which causes Perl_newPROG() to
skip out before setting PL_main_start; which is what the warning requires​:

(Inside of Perl_newprog())​:

  if (o->op_type == OP_STUB) {
  PL_comppad_name = 0;
  PL_compcv = 0;
  S_op_destroy(aTHX_ o);

  return; < -- Returns here
  }
  PL_main_root = op_scope(sawparens(scalarvoid(o)));
  PL_curcop = &PL_compiling;
  PL_main_start = LINKLIST(PL_main_root); < -- This is needed

(The warning check​:)

  if (PL_main_start)
  Perl_ck_warner(aTHX_ packWARN(WARN_VOID),
  "Too late to run CHECK block");

This warns correctly for example​:

perl -we'INIT { eval "CHECK {print qq​:in check in init\n​:}" } print "hi";'

Since the CHECK blocks don't actually get run, the warning should still
get generated. Does PL_main_start (and PL_main_root, etc..) need to get
set even when it's just an OP_STUB? Or is this an unlikely / illogical
situation?

-- Matthew Horsfall (alh)

@p5pRT
Copy link
Author

p5pRT commented Dec 18, 2011

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Dec 18, 2011

From @cpansprout

On Sat Dec 17 20​:36​:28 2011, alh wrote​:

Thanks for the report.

This is because when nothing is actually happening in the main scope of
the program it's treated as an OP_STUB which causes Perl_newPROG() to
skip out before setting PL_main_start; which is what the warning requires​:

(Inside of Perl_newprog())​:

     if \(o\->op\_type == OP\_STUB\) \{
        PL\_comppad\_name = 0;
        PL\_compcv = 0;
        S\_op\_destroy\(aTHX\_ o\);

        return; \< \-\- Returns here
    \}
    PL\_main\_root = op\_scope\(sawparens\(scalarvoid\(o\)\)\);
    PL\_curcop = &PL\_compiling;
    PL\_main\_start = LINKLIST\(PL\_main\_root\); \< \-\- This is needed

(The warning check​:)

            if \(PL\_main\_start\)
                Perl\_ck\_warner\(aTHX\_ packWARN\(WARN\_VOID\)\,
                               "Too late to run CHECK block"\);

This warns correctly for example​:

perl -we'INIT { eval "CHECK {print qq​:in check in init\n​:}" } print
"hi";'

Since the CHECK blocks don't actually get run, the warning should still
get generated. Does PL_main_start (and PL_main_root, etc..) need to get
set even when it's just an OP_STUB? Or is this an unlikely / illogical
situation?

It may be very unlikely, but I would not consider it illogical to want
to eval a generated CHECK block.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jan 10, 2012

From @cpansprout

On Sat Dec 17 23​:17​:09 2011, sprout wrote​:

On Sat Dec 17 20​:36​:28 2011, alh wrote​:

Thanks for the report.

This is because when nothing is actually happening in the main scope of
the program it's treated as an OP_STUB which causes Perl_newPROG() to
skip out before setting PL_main_start; which is what the warning
requires​:

(Inside of Perl_newprog())​:

     if \(o\->op\_type == OP\_STUB\) \{
        PL\_comppad\_name = 0;
        PL\_compcv = 0;
        S\_op\_destroy\(aTHX\_ o\);

        return; \< \-\- Returns here
    \}
    PL\_main\_root = op\_scope\(sawparens\(scalarvoid\(o\)\)\);
    PL\_curcop = &PL\_compiling;
    PL\_main\_start = LINKLIST\(PL\_main\_root\); \< \-\- This is needed

(The warning check​:)

            if \(PL\_main\_start\)
                Perl\_ck\_warner\(aTHX\_ packWARN\(WARN\_VOID\)\,
                               "Too late to run CHECK block"\);

This warns correctly for example​:

perl -we'INIT { eval "CHECK {print qq​:in check in init\n​:}" } print
"hi";'

Since the CHECK blocks don't actually get run, the warning should still
get generated. Does PL_main_start (and PL_main_root, etc..) need to get
set even when it's just an OP_STUB? Or is this an unlikely / illogical
situation?

It may be very unlikely, but I would not consider it illogical to want
to eval a generated CHECK block.

On the other hand, this bug report was about the main program, not an
empty eval. So I am apparently rather confused.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jan 10, 2012

From @ysth

On Tue, Jan 10, 2012 at 1​:58 PM, Father Chrysostomos wrote​:

On Sat Dec 17 23​:17​:09 2011, sprout wrote​:

On Sat Dec 17 20​:36​:28 2011, alh wrote​:

This is because when nothing is actually happening in the main scope of
the program it's treated as an OP_STUB which causes Perl_newPROG() to
skip out before setting PL_main_start; which is what the warning
requires​:
....
Since the CHECK blocks don't actually get run, the warning should still
get generated. Does PL_main_start (and PL_main_root, etc..) need to get
set even when it's just an OP_STUB?  Or is this an unlikely / illogical
situation?

It may be very unlikely, but I would not consider it illogical to want
to eval a generated CHECK block.

On the other hand, this bug report was about the main program, not an
empty eval.  So I am apparently rather confused.

This bug is only about a very unlikely to occur case, so is presumably
very low priority. On the other hand, given this bug, there may be
other undesirable consequences of not having PL_main_start set for an
empty main program. On the gripping hand, fixing that will require
significant diligence to see that no bugs are introduced.

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

2 participants