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
[PATCH] PERL_UNUSED_CONTEXT audit #13935
Comments
From @bulk88Created by @bulk88See attached patch. Perl Info
|
From @bulk880001-PERL_UNUSED_CONTEXT-audit.patchFrom fa479836a7bb587357407b408c00998da7b2bc56 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Tue, 17 Jun 2014 18:58:53 -0400
Subject: [PATCH] PERL_UNUSED_CONTEXT audit
make PERL_UNUSED_CONTEXT be poisoned, if the context will truly never be
used, then make sure it wont, an assignment to var that is never referenced
again will optimize away by CC
-Perl_refcounted_he_free added in commit 57ca3b03ba, a few days after
commit b6bbf3fa3e and 71ad1b0c38 started not using context in some build
permutations
-PerlIOUnix_setfd is positioned to avoid whitespace changes+C89
-rest of perlio, is vtable calls under PERL_IMPLICIT_SYS
-*rxres* use my_perl under COW
-pp_leavegiven, PERL_UNUSED_CONTEXT was wrong from its creation at
commit 96a5add60f , POPBLOCK and PL_curpm and PUTBACK all use my_perl
-Perl_dirp_dup, PERL_UNUSED_CONTEXT was correct from its creation at
commit 96a5add60f but made obsolete partially at commit 11a11ecf4b and
fully at commit 60b22aca14 , ptr_table_* uses my_perl
most changes are related to PERL_IMPLICIT_SYS redirecting memory allocation
through interp instance specific vtables
---
hv.c | 2 ++
perl.h | 2 +-
perlio.c | 26 +++++++++++++++++++++++++-
pp_ctl.c | 5 ++++-
regcomp.c | 2 ++
sv.c | 2 --
util.c | 5 ++++-
7 files changed, 38 insertions(+), 6 deletions(-)
diff --git a/hv.c b/hv.c
index db3ce63..09c5494 100644
--- a/hv.c
+++ b/hv.c
@@ -3462,7 +3462,9 @@ no action occurs in this case.
void
Perl_refcounted_he_free(pTHX_ struct refcounted_he *he) {
dVAR;
+#if ! defined(PERL_IMPLICIT_SYS) && defined(USE_ITHREADS)
PERL_UNUSED_CONTEXT;
+#endif
while (he) {
struct refcounted_he *copy;
diff --git a/perl.h b/perl.h
index f59eb6e..116b344 100644
--- a/perl.h
+++ b/perl.h
@@ -322,7 +322,7 @@
#endif
#ifdef USE_ITHREADS
-# define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl)
+# define PERL_UNUSED_CONTEXT (my_perl = NULL)
#else
# define PERL_UNUSED_CONTEXT
#endif
diff --git a/perlio.c b/perlio.c
index d41c2f5..1f9e819 100644
--- a/perlio.c
+++ b/perlio.c
@@ -2597,10 +2597,12 @@ PerlIOUnix_setfd(pTHX_ PerlIO *f, int fd, int imode)
}
}
#endif
+#if !defined(WIN32) || !defined(PERL_IMPLICIT_SYS)
+ PERL_UNUSED_CONTEXT;
+#endif
s->fd = fd;
s->oflags = imode;
PerlIOUnix_refcnt_inc(fd);
- PERL_UNUSED_CONTEXT;
}
IV
@@ -2628,7 +2630,9 @@ PerlIOUnix_seek(pTHX_ PerlIO *f, Off_t offset, int whence)
{
const int fd = PerlIOSelf(f, PerlIOUnix)->fd;
Off_t new_loc;
+#ifndef PERL_IMPLICIT_SYS
PERL_UNUSED_CONTEXT;
+#endif
if (PerlIOBase(f)->flags & PERLIO_F_NOTREG) {
#ifdef ESPIPE
SETERRNO(ESPIPE, LIB_INVARG);
@@ -2791,7 +2795,9 @@ PerlIOUnix_write(pTHX_ PerlIO *f, const void *vbuf, Size_t count)
Off_t
PerlIOUnix_tell(pTHX_ PerlIO *f)
{
+#ifndef PERL_IMPLICIT_SYS
PERL_UNUSED_CONTEXT;
+#endif
return PerlLIO_lseek(PerlIOSelf(f, PerlIOUnix)->fd, 0, SEEK_CUR);
}
@@ -2880,7 +2886,9 @@ typedef struct {
IV
PerlIOStdio_fileno(pTHX_ PerlIO *f)
{
+#ifndef PERL_IMPLICIT_SYS
PERL_UNUSED_CONTEXT;
+#endif
if (PerlIOValid(f)) {
FILE * const s = PerlIOSelf(f, PerlIOStdio)->stdio;
@@ -3419,7 +3427,9 @@ IV
PerlIOStdio_seek(pTHX_ PerlIO *f, Off_t offset, int whence)
{
FILE * const stdio = PerlIOSelf(f, PerlIOStdio)->stdio;
+#ifndef PERL_IMPLICIT_SYS
PERL_UNUSED_CONTEXT;
+#endif
return PerlSIO_fseek(stdio, offset, whence);
}
@@ -3428,7 +3438,9 @@ Off_t
PerlIOStdio_tell(pTHX_ PerlIO *f)
{
FILE * const stdio = PerlIOSelf(f, PerlIOStdio)->stdio;
+#ifndef PERL_IMPLICIT_SYS
PERL_UNUSED_CONTEXT;
+#endif
return PerlSIO_ftell(stdio);
}
@@ -3437,7 +3449,9 @@ IV
PerlIOStdio_flush(pTHX_ PerlIO *f)
{
FILE * const stdio = PerlIOSelf(f, PerlIOStdio)->stdio;
+#ifndef PERL_IMPLICIT_SYS
PERL_UNUSED_CONTEXT;
+#endif
if (PerlIOBase(f)->flags & PERLIO_F_CANWRITE) {
return PerlSIO_fflush(stdio);
@@ -3465,7 +3479,9 @@ PerlIOStdio_flush(pTHX_ PerlIO *f)
IV
PerlIOStdio_eof(pTHX_ PerlIO *f)
{
+#ifndef PERL_IMPLICIT_SYS
PERL_UNUSED_CONTEXT;
+#endif
return PerlSIO_feof(PerlIOSelf(f, PerlIOStdio)->stdio);
}
@@ -3473,7 +3489,9 @@ PerlIOStdio_eof(pTHX_ PerlIO *f)
IV
PerlIOStdio_error(pTHX_ PerlIO *f)
{
+#ifndef PERL_IMPLICIT_SYS
PERL_UNUSED_CONTEXT;
+#endif
return PerlSIO_ferror(PerlIOSelf(f, PerlIOStdio)->stdio);
}
@@ -3481,7 +3499,9 @@ PerlIOStdio_error(pTHX_ PerlIO *f)
void
PerlIOStdio_clearerr(pTHX_ PerlIO *f)
{
+#ifndef PERL_IMPLICIT_SYS
PERL_UNUSED_CONTEXT;
+#endif
PerlSIO_clearerr(PerlIOSelf(f, PerlIOStdio)->stdio);
}
@@ -3489,7 +3509,9 @@ PerlIOStdio_clearerr(pTHX_ PerlIO *f)
void
PerlIOStdio_setlinebuf(pTHX_ PerlIO *f)
{
+#ifndef PERL_IMPLICIT_SYS
PERL_UNUSED_CONTEXT;
+#endif
#ifdef HAS_SETLINEBUF
PerlSIO_setlinebuf(PerlIOSelf(f, PerlIOStdio)->stdio);
@@ -3573,7 +3595,9 @@ PerlIOStdio_fill(pTHX_ PerlIO *f)
{
FILE * stdio;
int c;
+#ifndef PERL_IMPLICIT_SYS
PERL_UNUSED_CONTEXT;
+#endif
if (PerlIO_lockcnt(f)) /* in use: abort ungracefully */
return -1;
stdio = PerlIOSelf(f, PerlIOStdio)->stdio;
diff --git a/pp_ctl.c b/pp_ctl.c
index 9cb6aba..8909dfd 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -397,7 +397,9 @@ S_rxres_restore(pTHX_ void **rsp, REGEXP *rx)
U32 i;
PERL_ARGS_ASSERT_RXRES_RESTORE;
+#ifndef PERL_ANY_COW
PERL_UNUSED_CONTEXT;
+#endif
RX_MATCH_COPY_FREE(rx);
RX_MATCH_COPIED_set(rx, *p);
@@ -427,7 +429,9 @@ S_rxres_free(pTHX_ void **rsp)
UV * const p = (UV*)*rsp;
PERL_ARGS_ASSERT_RXRES_FREE;
+#ifndef PERL_ANY_COW
PERL_UNUSED_CONTEXT;
+#endif
if (p) {
void *tmp = INT2PTR(char*,*p);
@@ -4459,7 +4463,6 @@ PP(pp_leavegiven)
I32 gimme;
SV **newsp;
PMOP *newpm;
- PERL_UNUSED_CONTEXT;
POPBLOCK(cx,newpm);
assert(CxTYPE(cx) == CXt_GIVEN);
diff --git a/regcomp.c b/regcomp.c
index 205c840..eb58a99 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -15963,7 +15963,9 @@ Perl_re_intuit_string(pTHX_ REGEXP * const r)
GET_RE_DEBUG_FLAGS_DECL;
PERL_ARGS_ASSERT_RE_INTUIT_STRING;
+#ifndef DEBUGGING
PERL_UNUSED_CONTEXT;
+#endif
DEBUG_COMPILE_r(
{
diff --git a/sv.c b/sv.c
index 8e3c4cf..e2e1a25 100644
--- a/sv.c
+++ b/sv.c
@@ -11977,8 +11977,6 @@ Perl_dirp_dup(pTHX_ DIR *const dp, CLONE_PARAMS *const param)
STRLEN len = 0;
long pos;
#endif
-
- PERL_UNUSED_CONTEXT;
PERL_ARGS_ASSERT_DIRP_DUP;
if (!dp)
diff --git a/util.c b/util.c
index 195402a..509023f 100644
--- a/util.c
+++ b/util.c
@@ -1105,8 +1105,9 @@ Perl_savesharedpv(pTHX_ const char *pv)
{
char *newaddr;
STRLEN pvlen;
-
+#ifndef PERL_IMPLICIT_SYS
PERL_UNUSED_CONTEXT;
+#endif
if (!pv)
return NULL;
@@ -1999,7 +2000,9 @@ Perl_new_warnings_bitfield(pTHX_ STRLEN *buffer, const char *const bits,
STRLEN size) {
const MEM_SIZE len_wanted =
sizeof(STRLEN) + (size > WARNsize ? size : WARNsize);
+#ifndef PERL_IMPLICIT_SYS
PERL_UNUSED_CONTEXT;
+#endif
PERL_ARGS_ASSERT_NEW_WARNINGS_BITFIELD;
buffer = (STRLEN*)
--
1.7.9.msysgit.0
|
From @bulk88This was very poorly smoked since my unthreaded and no-PERL_IMPLICIT_SYS threaded perls were crashing due to another open ticket due to a Dynaloder/LoadLibrary bug that is open in another ticket. -- |
From @tonycozOn Tue Jun 17 16:05:37 2014, bulk88 wrote:
This change: --- a/perl.h #ifdef USE_ITHREADS would need to be limited to -DDEBUGGING builds. I expected gcc to warn about this assignment if the value isn't used, but couldn't get it to happen. Tony |
The RT System itself - Status changed from 'new' to 'open' |
From @tonycozOn Tue Jun 17 16:05:37 2014, bulk88 wrote:
It fails fairly badly on POSIXish systems: cc -fstack-protector -L/usr/local/lib -o miniperl \ tony@mars:.../git/perl2$ gdb --args ./miniperl -w -Ilib -Idist/Exporter/lib -MExporter -e '<?>' Program received signal SIGSEGV, Segmentation fault. This particular crash is fixable with some changes to regen/reentr.pl to move the PERL_UNUSED_CONTEXT into a #else, but it continues to crash elsewhere after that is fixed: Program received signal SIGSEGV, Segmentation fault. So this patch isn't currently suitable for blead. Tony |
From @jhi
bulk88, if you take a look at the latest blead, I have been actually also working towards removing unused contexts (or making them conditional on whatever) (because I was turning on as many gcc -Wflags as I could easily). I haven't looked at your patch in detail, but I think you will find we covered many of the same spots. See for example: http://perl5.git.perl.org/perl.git/commit/23491f1decae17401c5c08e7f8a11e0d30f4f0e2 (hugmeir also did some similar work in early June, but I think that was your original inspiration) Also I removed unused dVAR (which I think under some cases are actually also dTHX): http://perl5.git.perl.org/perl.git/commit/23491f1decae17401c5c08e7f8a11e0d30f4f0e2 |
From [Unknown Contact. See original ticket]
bulk88, if you take a look at the latest blead, I have been actually also working towards removing unused contexts (or making them conditional on whatever) (because I was turning on as many gcc -Wflags as I could easily). I haven't looked at your patch in detail, but I think you will find we covered many of the same spots. See for example: http://perl5.git.perl.org/perl.git/commit/23491f1decae17401c5c08e7f8a11e0d30f4f0e2 (hugmeir also did some similar work in early June, but I think that was your original inspiration) Also I removed unused dVAR (which I think under some cases are actually also dTHX): http://perl5.git.perl.org/perl.git/commit/23491f1decae17401c5c08e7f8a11e0d30f4f0e2 |
From zefram@fysh.orgPoisoning my_perl in PERL_UNUSED_CONTEXT is a bad idae, and this patch -zefram |
@cpansprout - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#122122 (status was 'rejected')
Searchable as RT122122$
The text was updated successfully, but these errors were encountered: