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

[bug] sizeof(PerlInterpreter) is wrong in win32/win32.c #9029

Open
p5pRT opened this issue Sep 17, 2007 · 6 comments
Open

[bug] sizeof(PerlInterpreter) is wrong in win32/win32.c #9029

p5pRT opened this issue Sep 17, 2007 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 17, 2007

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

Searchable as RT45495$

@p5pRT
Copy link
Author

p5pRT commented Sep 17, 2007

From dk@tetsuo.karasik.eu.org

I've noticed that sizeof(PerlInterpreter) is different in win32/win32.c and
(f.ex) pp_sys.c, which might lead to strange bugs . The reason is that win32.c
declares

  #if !defined(PERLIO_IS_STDIO) && !defined(USE_SFIO)
  #define PerlIO FILE
  #endif

and perlio.h does

  #ifndef PerlIO
  /* ----------- PerlIO implementation ---------- */
  /* PerlIO not #define-d to something else - define the implementation */
  ...
  #define PERLIO_LAYERS 1
  ...
  #endif

whereas intrpvar.h declares

  #ifdef PERLIO_LAYERS
  PERLVARI(Iperlio, PerlIO *,NULL)
  PERLVARI(Iknown_layers, PerlIO_list_t *,NULL)
  PERLVARI(Idef_layerlist, PerlIO_list_t *,NULL)
  #endif

which is exactly the reason why sizeof(PerlInterpreter) is less in win32.c
than in core files. I've fixed this by the following patch​:

Inline Patch
--- win32.c.orig	2007-09-17 23:12:34.000000000 +0200
+++ win32.c	2007-09-17 22:16:24.000000000 +0200
@@ -54,6 +54,7 @@
 
 #if !defined(PERLIO_IS_STDIO) && !defined(USE_SFIO)
 #define PerlIO FILE
+#define PERLIO_LAYERS 1
 #endif
 
 #include <sys/stat.h>

but possibly , if I'm not mistaken, the default notion of PerlIO=FILE is obsolete\, so the removal of the whole if\-endif block will probably be even better\.
Perl Info

Flags:
    category=core
    severity=medium


Summary of my perl5 (revision 5 version 10 subversion 0 patchlevel 31876) configuration:
  Platform:
    osname=MSWin32, osvers=5.00, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -GF -W3 -Od -MD -Zi -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT  -DUTF8_FILENAME_SEMANTICS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
    optimize='-Od -MD -Zi',
    cppflags='-DWIN32'
    ccversion='11.00.7022', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug  -libpath:"c:\usr\local\perl\blead\lib\CORE"  -machine:x86'
    libpth=\lib
    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl59.lib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug  -libpath:"c:\usr\local\perl\blead\lib\CORE"  -machine:x86'


Characteristics of this binary (from libperl): 
  Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
                        PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
                        PERL_MALLOC_WRAP PL_OP_SLAB_ALLOC USE_ITHREADS
                        USE_LARGE_FILES USE_PERLIO
  Locally applied patches:
	DEVEL
  Built under MSWin32
  Compiled at Sep 17 2007 23:37:43
  %ENV:
  @INC:
    C:/home/src/perl-current/lib
    .

@p5pRT
Copy link
Author

p5pRT commented Sep 19, 2007

From @steve-m-hay

dk@​tetsuo.karasik.eu.org (via RT) wrote​:

# New Ticket Created by dk@​tetsuo.karasik.eu.org
# Please include the string​: [perl #45495]
# in the subject line of all future correspondence about this issue.
# <URL​: http​://rt.perl.org/rt3/Ticket/Display.html?id=45495 >
[...]
but possibly , if I'm not mistaken, the default notion of PerlIO=FILE
is
obsolete, so the removal of the whole if-endif block will probably be
even
better.

Which if-endif block are you referring to there?

Defining PERLIO_LAYERS 1 doesn't feel right if we're not using the
PerlIO implementation, but I'm not really sure. Removing obsolete code
sounds better, but I also don't know whether it really is dead or not.
Anyone know?

@p5pRT
Copy link
Author

p5pRT commented Sep 19, 2007

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

@p5pRT
Copy link
Author

p5pRT commented Dec 27, 2012

From @bulk88

On Wed Sep 19 06​:06​:13 2007, shay wrote​:

dk@​tetsuo.karasik.eu.org (via RT) wrote​:

# New Ticket Created by dk@​tetsuo.karasik.eu.org
# Please include the string​: [perl #45495]
# in the subject line of all future correspondence about this issue.
# <URL​: http​://rt.perl.org/rt3/Ticket/Display.html?id=45495 >
[...]
but possibly , if I'm not mistaken, the default notion of PerlIO=FILE
is
obsolete, so the removal of the whole if-endif block will probably be
even
better.

Which if-endif block are you referring to there?

Defining PERLIO_LAYERS 1 doesn't feel right if we're not using the
PerlIO implementation, but I'm not really sure. Removing obsolete code
sounds better, but I also don't know whether it really is dead or not.
Anyone know?

Still a problem in 5.17.6, attaching a diff of post processor of win32.c
and pp_hot.c. Yes the interp struct definitions are different.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

p5pRT commented Dec 27, 2012

From @bulk88

interpdiff.patch
--- C:\p517\perl\win32\pp_hot.i 
+++ C:\p517\perl\win32\win32.i 
@@ -1,13 +1,13 @@
-#line 1 "..\\pp_hot.c"
-#line 5000 "c:\\p517\\perl\\perl.h"
+#line 1 ".\\win32.c"
+#line 5000 "..\\lib\\CORE\\perl.h"
 
      struct interpreter {
-#line 1 "c:\\p517\\perl\\intrpvar.h"
+#line 1 "c:\\p517\\perl\\lib\\core\\intrpvar.h"
 
          SV            **Istack_sp;
 
          OP             *Iop;
-#line 39 "c:\\p517\\perl\\intrpvar.h"
+#line 39 "c:\\p517\\perl\\lib\\core\\intrpvar.h"
          SV            **Icurpad;
 
          SV            **Istack_base;
@@ -46,7 +46,7 @@
          SV             *Istatname;
 
          struct tms      Itimesbuf;
-#line 94 "c:\\p517\\perl\\intrpvar.h"
+#line 94 "c:\\p517\\perl\\lib\\core\\intrpvar.h"
 
          PMOP           *Icurpm;
 
@@ -160,7 +160,7 @@
          I32             Istatusvalue;
 
          I32             Istatusvalue_posix;
-#line 313 "c:\\p517\\perl\\intrpvar.h"
+#line 313 "c:\\p517\\perl\\lib\\core\\intrpvar.h"
 
          int             Isig_pending;
          int            *Ipsig_pend;
@@ -248,7 +248,7 @@
 
          struct interp_intern Isys_intern;
 
-#line 453 "c:\\p517\\perl\\intrpvar.h"
+#line 453 "c:\\p517\\perl\\lib\\core\\intrpvar.h"
 
          CV             *IDBcv;
          int             Igeneration;
@@ -264,7 +264,7 @@
          gid_t           Idelaymagic_egid;
          U32             Ian;
 
-#line 475 "c:\\p517\\perl\\intrpvar.h"
+#line 475 "c:\\p517\\perl\\lib\\core\\intrpvar.h"
          U32             Icop_seqmax;
 
          U32             Ievalseq;
@@ -309,11 +309,11 @@
          U32             Icollation_ix;
          char            Icollation_standard;
 
-#line 540 "c:\\p517\\perl\\intrpvar.h"
-
-#line 545 "c:\\p517\\perl\\intrpvar.h"
-
-#line 547 "c:\\p517\\perl\\intrpvar.h"
+#line 540 "c:\\p517\\perl\\lib\\core\\intrpvar.h"
+
+#line 545 "c:\\p517\\perl\\lib\\core\\intrpvar.h"
+
+#line 547 "c:\\p517\\perl\\lib\\core\\intrpvar.h"
          I8              Iutf8cache;
 
          char            Inumeric_standard;
@@ -323,7 +323,7 @@
          char           *Inumeric_name;
          SV             *Inumeric_radix_sv;
 
-#line 561 "c:\\p517\\perl\\intrpvar.h"
+#line 561 "c:\\p517\\perl\\lib\\core\\intrpvar.h"
 
          SV             *IASCII;
          SV             *ILatin1;
@@ -420,7 +420,7 @@
          struct IPerlDir *IDir;
          struct IPerlSock *ISock;
          struct IPerlProc *IProc;
-#line 669 "c:\\p517\\perl\\intrpvar.h"
+#line 669 "c:\\p517\\perl\\lib\\core\\intrpvar.h"
 
          PTR_TBL_t      *Iptr_table;
          AV             *Ibeginav_save;
@@ -434,15 +434,10 @@
          HV            **Istashpad;
          PADOFFSET       Istashpadmax;
          PADOFFSET       Istashpadix;
-#line 688 "c:\\p517\\perl\\intrpvar.h"
+#line 688 "c:\\p517\\perl\\lib\\core\\intrpvar.h"
 
          HV             *Icustom_op_names;
          HV             *Icustom_op_descs;
-
-         PerlIOl        *Iperlio;
-         PerlIO_list_t  *Iknown_layers;
-         PerlIO_list_t  *Idef_layerlist;
-#line 701 "c:\\p517\\perl\\intrpvar.h"
 
          SV             *Iencoding;
 
@@ -466,7 +461,7 @@
          share_proc_t    Isharehook;
          share_proc_t    Ilockhook;
 
-#line 731 "c:\\p517\\perl\\intrpvar.h"
+#line 731 "c:\\p517\\perl\\lib\\core\\intrpvar.h"
          share_proc_t    Iunlockhook;
 
          thrhook_proc_t  Ithreadhook;
@@ -474,7 +469,7 @@
          destroyable_proc_t Idestroyhook;
 
          despatch_signals_proc_t Isignalhook;
-#line 741 "c:\\p517\\perl\\intrpvar.h"
+#line 741 "c:\\p517\\perl\\lib\\core\\intrpvar.h"
 
          HV             *Iisarev;
 
@@ -497,9 +492,9 @@
          void          **Imy_cxt_list;
          int             Imy_cxt_size;
 
-#line 783 "c:\\p517\\perl\\intrpvar.h"
-
-#line 5015 "c:\\p517\\perl\\perl.h"
+#line 783 "c:\\p517\\perl\\lib\\core\\intrpvar.h"
+
+#line 5015 "..\\lib\\CORE\\perl.h"
      };

@toddr
Copy link
Member

toddr commented Feb 12, 2020

@bulk88 what actions do you recommend here?

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

3 participants