BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:

Anyone any idea what this error means?

Layer does not match this perl at C:/perl32/lib/IO/Socket.pm line 80, +<> line 1.

Which is this line:

socket($sock,$domain,$type,$protocol) or return undef;

Update: Thanks to perlbiotics, I ran the code with PERLIO_DEBUG=trace.log and these are the last few line of the trace produced:

828831.pl:9 Layer 1 is crlf 828831.pl:9 openn(crlf,'(Null)','rb',-1,0,0,00000000,1,0140F5C8) 828831.pl:9 Layer 0 is unix 828831.pl:9 Layer 0 is unix 828831.pl:9 PerlIO_push f=034589D0 unix rb 0344E1AC 828831.pl:9 5 _is_ a regular file 828831.pl:9 refcnt_inc: fd 5 refcnt=1 828831.pl:9 PerlIO_push f=034589D0 crlf rb 0344E1AC C:/perl32/lib/attributes.pm:91 refcnt_dec: fd 5 refcnt=0 C:/perl32/lib/attributes.pm:91 PerlIO_pop f=034589D0 crlf C:/perl32/lib/attributes.pm:91 PerlIO_pop f=034589D0 unix 828831.pl:70 refcnt_dec: fd 4 refcnt=0 828831.pl:70 PerlIO_pop f=034589CC crlf 828831.pl:70 PerlIO_pop f=034589CC unix C:/perl32/lib/IO/Socket.pm:80 Layer 1 is crlf C:/perl32/lib/IO/Socket.pm:80 openn(crlf,'(Null)','rb',4,0,0,00000000, +0,00000000) C:/perl32/lib/IO/Socket.pm:80 Layer 0 is unix C:/perl32/lib/IO/Socket.pm:80 Layer 0 is unix 828831.pl:0 Destruct 0344D834

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"

Replies are listed 'Best First'.
Re: Layer does not match this perl
by shmem (Chancellor) on Mar 20, 2010 at 16:56 UTC

    I found at least the location...
    This error is thrown in PerlIO_push() in perlio.c:

    PerlIO * PerlIO_push(pTHX_ PerlIO *f, PERLIO_FUNCS_DECL(*tab), const char *mode +, SV *arg) { if (tab->fsize != sizeof(PerlIO_funcs)) { mismatch: Perl_croak(aTHX_ "Layer does not match this perl"); } if (tab->size) { PerlIOl *l; if (tab->size < sizeof(PerlIOl)) { goto mismatch; }

    As for the meaning.... dunno. Has an incompatible IO layer been pushed onto $sock (wild guess) ?

      Thanks shmem I also found the source.

      The puzzling thing is, the code doesn't give that (or any other) error, when run normally. It only happens when run under the auspices of a binary debugger. Actually just an api tracer along the lines of strace.

      Which implies that the debugger is modifying the contents of memory, except I can run it on any number of other apps without problems. I can even run it perl.exe running any number of other scripts without this problem.

      I suspect that it has something to do with that hookey goto.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      *sigh* Reasonable code would be more like:

      if (tab->fsize != sizeof(PerlIO_funcs)) { Perl_croak( aTHX_ "%s (%d) does not match %s (%d)", "PerlIO layer function table size", tab->fsize, "size expected by this perl", sizeof(PerlIO_funcs) ); } if (tab->size) { PerlIOl *l; if (tab->size < sizeof(PerlIOl)) { Perl_croak( aTHX_ "%s (%d) smaller than %s (%d)", "PerlIO layer instance size", tab->size, "size expected by this perl", sizeof(PerlIOl) ); }

      See also http://perl5.git.perl.org/perl.git/blob?f=pod/perliol.pod.

      - tye