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

Error from exit in BEGIN {} #896

Closed
p5pRT opened this issue Nov 26, 1999 · 2 comments
Closed

Error from exit in BEGIN {} #896

p5pRT opened this issue Nov 26, 1999 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 26, 1999

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

Searchable as RT1829$

@p5pRT
Copy link
Author

p5pRT commented Nov 26, 1999

From mjtg@cus.cam.ac.uk

Is the error message appropriate in this case? The description in
perldiag is somewhat unhelpful​:

=item Callback called exit

(F) A subroutine invoked from an external package via perl_call_sv()
exited by calling exit.

Mike Guy

%perl -V
Summary of my perl5 (revision 5.0 version 5 subversion 62) configuration​:
  Platform​:
  osname=sunos, osvers=4.1.3, archname=sun4-sunos
  uname='sunos nmg1.csi. 4.1.3 1 sun4c '
  config_args='-Doptimise=-O -Uusethreads -des'
  hint=previous, useposix=true, d_sigaction=define
  usethreads=undef useperlio=undef d_sfio=undef
  use64bits=undef usemultiplicity=undef
  Compiler​:
  cc='gcc', optimize='-O', gccversion=2.7.2.3
  cppflags='-I/usr/local/include'
  ccflags ='-I/usr/local/include'
  stdchar='unsigned char', d_stdstdio=define, usevfork=true
  intsize=4, longsize=4, ptrsize=4, doublesize=8
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
  alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries​:
  ld='ld', ldflags =' -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib /usr/ucblib
  libs=-ldbm -ldl -lm -lc -lposix
  libc=/lib/libc.so.1.8, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
  cccdlflags='-fpic', lddlflags='-assert nodefinitions -L/usr/local/lib'

Characteristics of this binary (from libperl)​:
  Locally applied patches​:
  perldoc.temp
  install.w
  Built under sunos
  Compiled at Oct 27 1999 01​:31​:39
  @​INC​:
  /home/mjtg/perl5.005_62a/lib
  /home/mjtg/perl5.005_62a/lib
  /home/mjtg/perl5.005_62a/lib/site_perl
  .

@p5pRT
Copy link
Author

p5pRT commented Dec 1, 1999

From @gsar

On Fri, 26 Nov 1999 16​:44​:37 GMT, "M.J.T. Guy" wrote​:

        %perl \-we 'BEGIN \{ exit 1 \}'
        Callback called exit at \-e line 1\.
        BEGIN failed\-\-compilation aborted at \-e line 1\.
        %

Is the error message appropriate in this case? The description in
perldiag is somewhat unhelpful​:

I think the error is rather misguided for explicit exits. It is also
a constant annoyance for people who embed interpreters and execute bits
of code with perl_call_*(). I've added the attached patch.

It may even be better to turn it into an optional warning for
exceptional exits. Opinions welcome.

Sarathy
gsar@​ActiveState.com

Inline Patch
-----------------------------------8<-----------------------------------
Change 4609 by gsar@auger on 1999/12/01 18:43:49

	avoid "Callback called exit" error on intentional exit()

Affected files ...

... //depot/perl/embedvar.h#83 edit
... //depot/perl/intrpvar.h#54 edit
... //depot/perl/objXSUB.h#83 edit
... //depot/perl/perl.c#196 edit
... //depot/perl/perl.h#203 edit
... //depot/perl/pp_ctl.c#165 edit

Differences ...

==== //depot/perl/embedvar.h#83 (text+w) ====
Index: perl/embedvar.h
--- perl/embedvar.h.~1~	Wed Dec  1 10:43:52 1999
+++ perl/embedvar.h	Wed Dec  1 10:43:52 1999
@@ -241,6 +241,7 @@
 #define PL_eval_root		(PERL_GET_INTERP->Ieval_root)
 #define PL_eval_start		(PERL_GET_INTERP->Ieval_start)
 #define PL_evalseq		(PERL_GET_INTERP->Ievalseq)
+#define PL_exit_flags		(PERL_GET_INTERP->Iexit_flags)
 #define PL_exitlist		(PERL_GET_INTERP->Iexitlist)
 #define PL_exitlistlen		(PERL_GET_INTERP->Iexitlistlen)
 #define PL_expect		(PERL_GET_INTERP->Iexpect)
@@ -506,6 +507,7 @@
 #define PL_eval_root		(vTHX->Ieval_root)
 #define PL_eval_start		(vTHX->Ieval_start)
 #define PL_evalseq		(vTHX->Ievalseq)
+#define PL_exit_flags		(vTHX->Iexit_flags)
 #define PL_exitlist		(vTHX->Iexitlist)
 #define PL_exitlistlen		(vTHX->Iexitlistlen)
 #define PL_expect		(vTHX->Iexpect)
@@ -908,6 +910,7 @@
 #define PL_eval_root		(aTHXo->interp.Ieval_root)
 #define PL_eval_start		(aTHXo->interp.Ieval_start)
 #define PL_evalseq		(aTHXo->interp.Ievalseq)
+#define PL_exit_flags		(aTHXo->interp.Iexit_flags)
 #define PL_exitlist		(aTHXo->interp.Iexitlist)
 #define PL_exitlistlen		(aTHXo->interp.Iexitlistlen)
 #define PL_expect		(aTHXo->interp.Iexpect)
@@ -1174,6 +1177,7 @@
 #define PL_Ieval_root		PL_eval_root
 #define PL_Ieval_start		PL_eval_start
 #define PL_Ievalseq		PL_evalseq
+#define PL_Iexit_flags		PL_exit_flags
 #define PL_Iexitlist		PL_exitlist
 #define PL_Iexitlistlen		PL_exitlistlen
 #define PL_Iexpect		PL_expect

==== //depot/perl/intrpvar.h#54 (text) ====
Index: perl/intrpvar.h
--- perl/intrpvar.h.~1~	Wed Dec  1 10:43:52 1999
+++ perl/intrpvar.h	Wed Dec  1 10:43:52 1999
@@ -56,6 +56,7 @@
 					/* top fd to pass to subprocesses */
 PERLVAR(Imultiline,	int)		/* $*--do strings hold >1 line? */
 PERLVAR(Istatusvalue,	I32)		/* $? */
+PERLVAR(Iexit_flags,	U8)		/* was exit() unexpected, etc. */
 #ifdef VMS
 PERLVAR(Istatusvalue_vms,U32)
 #endif

==== //depot/perl/objXSUB.h#83 (text+w) ====
Index: perl/objXSUB.h
--- perl/objXSUB.h.~1~	Wed Dec  1 10:43:52 1999
+++ perl/objXSUB.h	Wed Dec  1 10:43:52 1999
@@ -148,6 +148,8 @@
 #define PL_eval_start		(*Perl_Ieval_start_ptr(aTHXo))
 #undef  PL_evalseq
 #define PL_evalseq		(*Perl_Ievalseq_ptr(aTHXo))
+#undef  PL_exit_flags
+#define PL_exit_flags		(*Perl_Iexit_flags_ptr(aTHXo))
 #undef  PL_exitlist
 #define PL_exitlist		(*Perl_Iexitlist_ptr(aTHXo))
 #undef  PL_exitlistlen

==== //depot/perl/perl.c#196 (text) ====
Index: perl/perl.c
--- perl/perl.c.~1~	Wed Dec  1 10:43:52 1999
+++ perl/perl.c	Wed Dec  1 10:43:52 1999
@@ -1406,7 +1406,7 @@
 	    /* my_exit() was called */
 	    PL_curstash = PL_defstash;
 	    FREETMPS;
-	    if (PL_statusvalue)
+	    if (PL_statusvalue && !(PL_exit_flags & PERL_EXIT_EXPECTED))
 		Perl_croak(aTHX_ "Callback called exit");
 	    my_exit_jump();
 	    /* NOTREACHED */
@@ -1530,7 +1530,7 @@
 	/* my_exit() was called */
 	PL_curstash = PL_defstash;
 	FREETMPS;
-	if (PL_statusvalue)
+	if (PL_statusvalue && !(PL_exit_flags & PERL_EXIT_EXPECTED))
 	    Perl_croak(aTHX_ "Callback called exit");
 	my_exit_jump();
 	/* NOTREACHED */
@@ -3169,7 +3169,7 @@
 	    PL_curstash = PL_defstash;
 	    PL_curcop = &PL_compiling;
 	    CopLINE_set(PL_curcop, oldline);
-	    if (PL_statusvalue) {
+	    if (PL_statusvalue && !(PL_exit_flags & PERL_EXIT_EXPECTED)) {
 		if (paramList == PL_beginav)
 		    Perl_croak(aTHX_ "BEGIN failed--compilation aborted");
 		else

==== //depot/perl/perl.h#203 (text) ====
Index: perl/perl.h
--- perl/perl.h.~1~	Wed Dec  1 10:43:52 1999
+++ perl/perl.h	Wed Dec  1 10:43:52 1999
@@ -1592,6 +1592,9 @@
 #   define STATUS_ALL_FAILURE	(PL_statusvalue = 1)
 #endif
 
+/* flags in PL_exit_flags for nature of exit() */
+#define PERL_EXIT_EXPECTED	0x01
+
 #ifndef MEMBER_TO_FPTR
 #define MEMBER_TO_FPTR(name)		name
 #endif

==== //depot/perl/pp_ctl.c#165 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c.~1~	Wed Dec  1 10:43:52 1999
+++ perl/pp_ctl.c	Wed Dec  1 10:43:52 1999
@@ -2394,6 +2394,7 @@
 	    anum = 0;
 #endif
     }
+    PL_exit_flags |= PERL_EXIT_EXPECTED;
     my_exit(anum);
     PUSHs(&PL_sv_undef);
     RETURN;
End of Patch.

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