summaryrefslogtreecommitdiff
path: root/util.c
Commit message (Collapse)AuthorAgeFilesLines
...
* g++ -DPERL_GLOBAL_STRUCT_PRIVATE died on this.Jarkko Hietaniemi2014-06-211-1/+1
|
* Revert "/* NOTREACHED */ belongs *before* the unreachable."Jarkko Hietaniemi2014-06-191-10/+5
| | | | | | This reverts commit 148f39b7de6eae9ddd59e0b0aff691d6abea7aca. (Still needs more work, but wanted to see how well this passed with Jenkins.)
* /* NOTREACHED */ belongs *before* the unreachable.Jarkko Hietaniemi2014-06-191-5/+10
| | | | | | Definitely not *after* it. It marks the start of the unreachable, not the first unrechable line. And if they are in that order, it looks better to linebreak after the lint hint.
* Silence several -Wunused-parameter warnings about my_perlBrian Fraser2014-06-131-0/+8
| | | | | | | | This meant sprinkling some PERL_UNUSED_CONTEXT invocations, as well as stopping some functions from getting my_perl in the first place; all of the functions in the latter category are internal (S_ prefix and s or i in embed.fnc), so this should be both safe and economical.
* Added several missing PERL_UNUSED_RESULT()Brian Fraser2014-06-131-2/+2
|
* Mark several functions with __attribute__noreturn__Brian Fraser2014-06-131-4/+4
| | | | | Namely, die_nocontext, die, die_sv, and screaminstr. They all croak and never return, so let's mark them as non-returning.
* Adding missing SVfARG() invocationsBrian Fraser2014-06-131-7/+8
| | | | This silences a chunk of warnings under -Wformat
* Adding missing HEKfARG() invocationsBrian Fraser2014-06-131-1/+1
| | | | This silences a chunk of warnings under -Wformat
* C backtrace tweaks.Jarkko Hietaniemi2014-06-111-7/+27
| | | | | | | | | Rename the environment variable that triggers the backtrace before warns and croaks as PERL_USE_C_BACKTRACE_ON_ERROR (and correspondingly, the define as USE_C_BACKTRACE_ON_ERROR). Pod cleanups and updates, and move the needed #includes from perl.h to util.c since that's the only place where they are needed.
* Removed NeXT supportBrian Fraser2014-06-111-4/+0
|
* Add C backtrace API.Jarkko Hietaniemi2014-06-071-0/+664
| | | | | | | | Useful for at least debugging. Supported in Linux and OS X (possibly to some extent in *BSD). See perlhacktips for details.
* Use C locale for "$!" ouside 'use locale' scopeKarl Williamson2014-06-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The stringification of $! has long been an outlier in Perl locale handling. The theory has been that these operating system messages are likely to be of use to the final user, and should be in their language. Things like No space left on device Can't fork are not something the program is likely to handle, but could be meaningfully helpful to the end-user. There are problems with this though. One is that many perl messages are in English, with the $! appended to them, so that the resultant message is of mixed language, and may need to be translated anyway. Things like No space left on device probably won't need the remaining portion of the message to give someone a clear indication as to what's wrong. But there are many other messages where both the OS error and the Perl error would be needed togther to understand the problem. An on-line translation tool can be used to do this. Another problem is that it can lead to garbage coming out on the user's terminal when the program is not expecting UTF-8, but the underlying locale is UTF-8. This is what happens in Bug #112208, and another that was merged with it. It's a lot harder to translate mojibake via an online tool than English. This commit solves that by using the C locale for messages, except within the scope of 'use locale'. It is extremely likely that the messages in the C locale will be English, but if not they will be ASCII, and there will be no garbage printed. A program that says "use locale" is indicating that it has the intelligence necessary to deal with locales.
* Use PERL_UNUSED_RESULT.Jarkko Hietaniemi2014-06-021-3/+1
| | | | | | | (1) Enhance its description. (2) Simplify it: define only if has warn_unused_result. (3) Make it use STMT_START { ... } STMT_END to be less GNU-extensiony. (4) Redo 04783dc7 ("fix 'ignoring return value' compiler warnings") with it.
* perlapi: Clarify some instances where NUL is or isn't permittedKarl Williamson2014-05-301-2/+3
| | | | | | Some functions that take a string/length pair can have embedded NULs and don't have to be NUL terminated; others are the opposite. This adds text to clarify the issue.
* Wrap various pod uses of NUL with C<>Karl Williamson2014-05-301-8/+8
| | | | | | This makes the uses of this consistent in our pods. Also changed one use of the word 'buffer' into 'string', the latter being more appropriate.
* fcntl receiving -1 from fileno, fcntl failing.Jarkko Hietaniemi2014-05-291-8/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Also very few spots of negative numgroups for getgroups(), and fgetc() return, but almost all checking is for fcntl.) (merged fix for perl #121743 and perl #121745: hopefully picked up all the fixes-to-fixes from the ticket...) Fix for Coverity perl5 CIDs 28990..29003,29005..29011,29013, 45354,45363,49926: Argument cannot be negative (NEGATIVE_RETURNS) fd is passed to a parameter that cannot be negative. and CIDs 29004, 29012: Argument cannot be negative (NEGATIVE_RETURNS) num_groups is passed to a parameter that cannot be negative and because of CIDs 29005 and 29006 also CID 28924. In the first set of issues a fd is retrieved from PerlIO_fileno, and that is then used in places like fstat(), fchown(), dup(), etc., without checking whether the fd is valid (>=0). In the second set of issues a potentially negative number is potentially passed to getgroups(). The CIDs 29005 and 29006 were a bit messy: fixing them needed also resolving CID 28924 where the return value of fstat() was ignored, and for completeness adding two croak calls (with perldiag updates): a bit of a waste since it's suidperl code.
* Insert asserts to paths suspected by Coverity.Jarkko Hietaniemi2014-05-291-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Coverity suspects paths like this: (1) p = foo(); if (!p) p = bar(); baz(p->q); since it cannot prove that p is always non-NULL at the dereference. (2) Or simply something like: mg = mg_find(...); foo(mg->blah); Since mg_find() can fail returning NULL. Adding assert() calls before the dereferences. Testing with -DDEBUGGING. Hopefully there are regular smokes doing the same. [perl #121894] Fix for Coverity perl5 CIDs 28950,28952..28955,28964,28967,28970..28795,49921: CID ...: Dereference after null check (FORWARD_NULL) var_deref_op: Dereferencing null pointer p->q (TODO: Coverity perl5 CIDs 28962,28968,28969: the same issue, but would conflict with already in-flight changes, prepare catch-up patch later.) --- dist/Data-Dumper/Dumper.xs | 1 + dump.c | 1 + ext/Devel-Peek/Peek.xs | 1 + ext/XS-APItest/APItest.xs | 1 + mg.c | 2 ++ mro.c | 4 +++- op.c | 4 ++++ perlio.c | 1 + pp_hot.c | 5 +++-- regcomp.c | 3 +++ regexec.c | 5 ++++- universal.c | 2 +- util.c | 4 +++- 13 files changed, 28 insertions(+), 6 deletions(-) diff --git a/dist/Data-Dumper/Dumper.xs b/dist/Data-Dumper/Dumper.xs index 12c4ebd..23e0cf4 100644 --- a/dist/Data-Dumper/Dumper.xs +++ b/dist/Data-Dumper/Dumper.xs @@ -641,6 +641,7 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv, else { sv_pattern = val; } + assert(sv_pattern); rval = SvPV(sv_pattern, rlen); rend = rval+rlen; slash = rval; diff --git a/dump.c b/dump.c index 59be3e0..c2d72fd 100644 --- a/dump.c +++ b/dump.c @@ -471,6 +471,7 @@ Perl_sv_peek(pTHX_ SV *sv) finish: while (unref--) sv_catpv(t, ")"); + /* XXX when is sv ever NULL? */ if (TAINTING_get && SvTAINTED(sv)) sv_catpv(t, " [tainted]"); return SvPV_nolen(t); diff --git a/ext/Devel-Peek/Peek.xs b/ext/Devel-Peek/Peek.xs index 679efa5..b20fa94 100644 --- a/ext/Devel-Peek/Peek.xs +++ b/ext/Devel-Peek/Peek.xs @@ -450,6 +450,7 @@ PPCODE: BOOT: { CV * const cv = get_cvn_flags("Devel::Peek::Dump", 17, 0); + assert(cv); cv_set_call_checker(cv, S_ck_dump, (SV *)cv); XopENTRY_set(&my_xop, xop_name, "Dump"); diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs index a51924d..18ba381 100644 --- a/ext/XS-APItest/APItest.xs +++ b/ext/XS-APItest/APItest.xs @@ -2096,6 +2096,7 @@ newCONSTSUB(stash, name, flags, sv) break; } EXTEND(SP, 2); + assert(mycv); PUSHs( CvCONST(mycv) ? &PL_sv_yes : &PL_sv_no ); PUSHs((SV*)CvGV(mycv)); diff --git a/mg.c b/mg.c index 76912bd..7f3339a 100644 --- a/mg.c +++ b/mg.c @@ -1675,6 +1675,7 @@ Perl_magic_clearisa(pTHX_ SV *sv, MAGIC *mg) same function. */ mg = mg_find(mg->mg_obj, PERL_MAGIC_isa); + assert(mg); if (SvTYPE(mg->mg_obj) == SVt_PVAV) { /* multiple stashes */ SV **svp = AvARRAY((AV *)mg->mg_obj); I32 items = AvFILLp((AV *)mg->mg_obj) + 1; @@ -3437,6 +3438,7 @@ Perl_magic_copycallchecker(pTHX_ SV *sv, MAGIC *mg, SV *nsv, sv_magic(nsv, &PL_sv_undef, mg->mg_type, NULL, 0); nmg = mg_find(nsv, mg->mg_type); + assert(nmg); if (nmg->mg_flags & MGf_REFCOUNTED) SvREFCNT_dec(nmg->mg_obj); nmg->mg_ptr = mg->mg_ptr; nmg->mg_obj = SvREFCNT_inc_simple(mg->mg_obj); diff --git a/mro.c b/mro.c index 1b37ca7..ccf4bf4 100644 --- a/mro.c +++ b/mro.c @@ -638,12 +638,14 @@ Perl_mro_isa_changed_in(pTHX_ HV* stash) hv_storehek(mroisarev, namehek, &PL_sv_yes); } - if((SV *)isa != &PL_sv_undef) + if ((SV *)isa != &PL_sv_undef) { + assert(namehek); mro_clean_isarev( isa, HEK_KEY(namehek), HEK_LEN(namehek), HvMROMETA(revstash)->isa, HEK_HASH(namehek), HEK_UTF8(namehek) ); + } } } } diff --git a/op.c b/op.c index 796cb03..79621ce 100644 --- a/op.c +++ b/op.c @@ -2907,6 +2907,7 @@ S_my_kid(pTHX_ OP *o, OP *attrs, OP **imopsp) S_cant_declare(aTHX_ o); } else if (attrs) { GV * const gv = cGVOPx_gv(cUNOPo->op_first); + assert(PL_parser); PL_parser->in_my = FALSE; PL_parser->in_my_stash = NULL; apply_attrs(GvSTASH(gv), @@ -2929,6 +2930,7 @@ S_my_kid(pTHX_ OP *o, OP *attrs, OP **imopsp) else if (attrs && type != OP_PUSHMARK) { HV *stash; + assert(PL_parser); PL_parser->in_my = FALSE; PL_parser->in_my_stash = NULL; @@ -10229,6 +10231,7 @@ Perl_ck_split(pTHX_ OP *o) op_append_elem(OP_SPLIT, o, newDEFSVOP()); kid = kid->op_sibling; + assert(kid); scalar(kid); if (!kid->op_sibling) @@ -10902,6 +10905,7 @@ Perl_cv_set_call_checker(pTHX_ CV *cv, Perl_call_checker ckfun, SV *ckobj) MAGIC *callmg; sv_magic((SV*)cv, &PL_sv_undef, PERL_MAGIC_checkcall, NULL, 0); callmg = mg_find((SV*)cv, PERL_MAGIC_checkcall); + assert(callmg); if (callmg->mg_flags & MGf_REFCOUNTED) { SvREFCNT_dec(callmg->mg_obj); callmg->mg_flags &= ~MGf_REFCOUNTED; diff --git a/perlio.c b/perlio.c index d4c43d0..e6ff9e4 100644 --- a/perlio.c +++ b/perlio.c @@ -2225,6 +2225,7 @@ PerlIOBase_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags) PerlIO_funcs * const self = PerlIOBase(o)->tab; SV *arg = NULL; char buf[8]; + assert(self); PerlIO_debug("PerlIOBase_dup %s f=%p o=%p param=%p\n", self ? self->name : "(Null)", (void*)f, (void*)o, (void*)param); diff --git a/pp_hot.c b/pp_hot.c index 2cccc48..9c9d1e9 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -3078,6 +3078,7 @@ S_method_common(pTHX_ SV* meth, U32* hashp) const HE* const he = hv_fetch_ent(stash, meth, 0, *hashp); if (he) { gv = MUTABLE_GV(HeVAL(he)); + assert(stash); if (isGV(gv) && GvCV(gv) && (!GvCVGEN(gv) || GvCVGEN(gv) == (PL_sub_generation + HvMROMETA(stash)->cache_gen))) @@ -3085,9 +3086,9 @@ S_method_common(pTHX_ SV* meth, U32* hashp) } } + assert(stash || packsv); gv = gv_fetchmethod_sv_flags(stash ? stash : MUTABLE_HV(packsv), - meth, GV_AUTOLOAD | GV_CROAK); - + meth, GV_AUTOLOAD | GV_CROAK); assert(gv); return isGV(gv) ? MUTABLE_SV(GvCV(gv)) : MUTABLE_SV(gv); diff --git a/regcomp.c b/regcomp.c index eaee604..3d49827 100644 --- a/regcomp.c +++ b/regcomp.c @@ -2007,6 +2007,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, }); re_trie_maxbuff = get_sv(RE_TRIE_MAXBUF_NAME, 1); + assert(re_trie_maxbuff); if (!SvIOK(re_trie_maxbuff)) { sv_setiv(re_trie_maxbuff, RE_TRIE_MAXBUF_INIT); } @@ -14920,6 +14921,7 @@ S_set_ANYOF_arg(pTHX_ RExC_state_t* const pRExC_state, av_store(av, 0, (runtime_defns) ? SvREFCNT_inc(runtime_defns) : &PL_sv_undef); if (swash) { + assert(cp_list); av_store(av, 1, swash); SvREFCNT_dec_NN(cp_list); } @@ -16609,6 +16611,7 @@ S_dumpuntil(pTHX_ const regexp *r, const regnode *start, const regnode *node, last= plast; while (PL_regkind[op] != END && (!last || node < last)) { + assert(node); /* While that wasn't END last time... */ NODE_ALIGN(node); op = OP(node); diff --git a/regexec.c b/regexec.c index 362390b..ffab4f2 100644 --- a/regexec.c +++ b/regexec.c @@ -7010,6 +7010,8 @@ no_silent: sv_commit = &PL_sv_yes; sv_yes_mark = &PL_sv_no; } + assert(sv_err); + assert(sv_mrk); sv_setsv(sv_err, sv_commit); sv_setsv(sv_mrk, sv_yes_mark); } @@ -7620,6 +7622,7 @@ Perl__get_regclass_nonbitmap_data(pTHX_ const regexp *prog, *only_utf8_locale_ptr = ary[2]; } else { + assert(only_utf8_locale_ptr); *only_utf8_locale_ptr = NULL; } @@ -7641,7 +7644,7 @@ Perl__get_regclass_nonbitmap_data(pTHX_ const regexp *prog, } else if (doinit && ((si && si != &PL_sv_undef) || (invlist && invlist != &PL_sv_undef))) { - + assert(si); sw = _core_swash_init("utf8", /* the utf8 package */ "", /* nameless */ si, diff --git a/universal.c b/universal.c index a29696d..65e02df 100644 --- a/universal.c +++ b/universal.c @@ -67,7 +67,7 @@ S_isa_lookup(pTHX_ HV *stash, const char * const name, STRLEN len, U32 flags) if (our_stash) { HEK *canon_name = HvENAME_HEK(our_stash); if (!canon_name) canon_name = HvNAME_HEK(our_stash); - + assert(canon_name); if (hv_common(isa, NULL, HEK_KEY(canon_name), HEK_LEN(canon_name), HEK_FLAGS(canon_name), HV_FETCH_ISEXISTS, NULL, HEK_HASH(canon_name))) { diff --git a/util.c b/util.c index b90abe5..cd0afb6 100644 --- a/util.c +++ b/util.c @@ -850,15 +850,17 @@ Perl_fbm_instr(pTHX_ unsigned char *big, unsigned char *bigend, SV *littlestr, U { const MAGIC *const mg = mg_find(littlestr, PERL_MAGIC_bm); - const unsigned char * const table = (const unsigned char *) mg->mg_ptr; const unsigned char *oldlittle; + assert(mg); + --littlelen; /* Last char found by table lookup */ s = big + littlelen; little += littlelen; /* last char */ oldlittle = little; if (s < bigend) { + const unsigned char * const table = (const unsigned char *) mg->mg_ptr; I32 tmp; top2: -- 1.8.5.2 (Apple Git-48)
* Reindent the block. Whitespace-only change.Jarkko Hietaniemi2014-05-291-46/+46
| | | | Followup to 99e8c5.
* Fix false nesting.Jarkko Hietaniemi2014-05-291-5/+5
| | | | | | | | | [perl #121744] Fix for Coverity perl5 CID 29014: Nesting level does not match indentation (NESTING_INDENT_MISMATCH) (Reindentation of the whole "if (!PL_use_safe_putenv)" block will follow.)
* put va_end() in the right placeTony Cook2014-05-291-1/+1
|
* add va_end() calls where missing for a va_start() or va_end().Jarkko Hietaniemi2014-05-291-0/+1
| | | | | | | | | | | | | Fix for Coverity perl5 CIDs 29225, 29226, 29227, 29228, 29229: Missing varargs init or cleanup (VARARGS) missing va_end: va_end was not called for foo. Use of va_args must be finished off with va_end (in other words, use of va_start or va_copy must be bracketed off with va_end). In most platforms va_end is a no-op, but in some platforms it is required for proper cleanup (or face stack smash, or memory leak). Tony: move va_start() out of the declaration block
* Use the C_ARRAY_LENGTH.Jarkko Hietaniemi2014-05-281-2/+2
| | | | | | | | | | | | Use the C_ARRAY_LENGTH instead of sizeof(c_array)/sizeof(c_array[0]) or sizeof(c_array)/sizeof(type_of_element_in_c_array), and C_ARRAY_END for c_array + C_ARRAY_LENGTH(c_array). While doing this found potential off-by-one error in sv.c:Perl_sv_magic: how > C_ARRAY_LENGTH(PL_magic_data) should probably have been how >= C_ARRAY_LENGTH(PL_magic_data) No tests fail, but this seems to be more of an internal sanity check.
* PERL_GLOBAL_STRUCT threads issueDavid Mitchell2014-04-091-0/+4
| | | | | | | | | | | | | | | | | | | | | A test in op/threads.t roughly equivalent to this: use threads; sub f {}; async \&f; was randomly failing smokes under the combination of PERL_GLOBAL_STRUCT and ASan. This is due to the fact that, under PERL_GLOBAL_STRUCT, "global" vars are actually allocated, and are freed as the very last thing before exiting (later than perl_destruct()). In the code above, the created thread is still exeecuting at this point, and so may access those "global" vars. ASan can detect that such a var is being accessed after being freed; in this case due to PL_ppaddr being indexed in call_sv(). This is easily fixed using the PL_veto_cleanup mechanism; don't do those final frees if there are still threads running.
* Avoid recalculating sub name hash in util.c:get_db_subFather Chrysostomos2014-02-161-3/+2
|
* [perl #121255] Call set-magic when setting $DB::subFather Chrysostomos2014-02-161-0/+1
| | | | | | Otherwise UTF8 length caches will not be reset, resulting in panicks when ${^UTF8CACHE} is -1 or wrongs answers from length($DB::sub) when ${^UTF8CACHE} is 1.
* util.c: Add comment.Karl Williamson2014-02-051-1/+2
| | | | I wonder if we need to worry about compatibility with a 1994 libc?
* Fix the prototypes of some functions without contextBrian Fraser2014-02-051-2/+2
| | | | Their prototypes are (void), but the implementation was ()
* rename sTHX to PERL_MEMORY_DEBUG_HEADER_SIZEDavid Mitchell2014-01-201-10/+10
| | | | | | | | | Originally this macro evaluated to the size of the THX pointer; this was used with the memory pool facility to store the context of the caller of the malloc() for debugging. Later, the header of the malloc() stored more than just the context, so sTHX became a mismoner. Rename it to something less misleading.
* util.c: A couple of defines to simplify #ifdef mazeFather Chrysostomos2014-01-161-16/+20
| | | | | No real simplification in terms of the number of #ifdefs, but more readability (hopefully).
* PERL_DEBUG_READONLY_COWFather Chrysostomos2014-01-161-20/+124
| | | | | | | | | | | | | | | | | | | | | | Make perls compiled with -Accflags=-DPERL_DEBUG_READONLY_COW to turn COW buffer violations into crashes. We do this using mmap to allocate memory and then mprotect to mark memory as read-only when buffers are shared. We have to do this at the safesysmalloc level, because some code does SvPV_set with buffers it allocates on its own via safemalloc(). Unfortunately this means many things are allocated using mmap that will never be marked read-only, slowing things down considerably, but I see no other way. Because munmap and mprotect need to know the length, we use the existing sTHX/perl_memory_debug_header mechanism used already by PERL_TRACK_MEMPOOL and store the size there (as PERL_POISON already does when PERL_TRACK_MEMPOOL is enabled). perl_memory_debug_header is a struct positioned at the beginning of every allocated buffer, for tracking things.
* Extract version routines into two new filesFather Chrysostomos2014-01-041-939/+1
| | | | | | | | | | | | | This is to make synchronisation between the CPAN distribution and the perl core easier. The files have different extensions to match what the CPAN distribu- tion will have. vutil.c is a separate compilation unit that the CPAN dist already has. vxs.inc will be included by vxs.xs (vxs.c is obvi- ously alreday taken, being generated from vxs.xs). In the perl core util.c includes vutil.c and universal.c includes vxs.inc.
* Improve rcatline bad fh warningsFather Chrysostomos2013-12-291-1/+2
| | | | | | | | | | | This is not helpful: append I/O operator() on closed filehandle STDIN at - line 3. append I/O operator() on closed filehandle STDIN at - line 4. (Are you trying to call append I/O operator() on dirhandle STDIN?) That .=<> compiles to a separate op from <> is an implementation detail, so show ‘readline()’ as we do with <>.
* perlapi: Consistent spaces after dotsFather Chrysostomos2013-12-291-9/+11
| | | | plus some typo fixes. I probably changed some things in perlintern, too.
* Purge sfio support, which has been broken for a decade.Nicholas Clark2013-12-271-10/+3
| | | | | | | | | | | The last Perl release that built with -Dusesfio was v5.8.0, and even that failed many regression tests. Every subsequent release fails to build, and in the decade that has passed we have had no bug reports about this. So it's safe to delete all the code. The Configure related code will be purged in a subsequent commit. 2 references to sfio intentionally remain in fakesdio.h and nostdio.h, as these appear to be for using its stdio API-compatibility layer.
* Fix sfio breakage caused by the fix for RT #78494.Nicholas Clark2013-12-271-2/+2
| | | | | | | | | | | | | Commit 2e0cfa16dea85dd3 (Feb 2011) fixed RT #78494, but inadvertently broke non-PerlIO configurations. -Uuseperlio was restored in March 2011 with commit b6ae43b72863e12d, but this change is needed to restore the sfio build. This is the last fix needed to get blead building with -Dusesfio, after 10 years of breakage. However, many many tests still fail (and one hangs). Note, specifically this is only tested with sfio97. Perl is making a couple of cheating assumptions which break with sfio2005, and I've not attempted to fix Perl's naughtiness to get it to build with current sfio. (Nor has anyone else in the past 8 years, it would seem. Or even reported a problem.)
* Fix a typo introduced in Nov 2008 by commit 4ee3916907333148.Nicholas Clark2013-12-271-1/+1
| | | | | One use of dSAVE_ERRNO was mistyped as dSAVED_ERRNO, but as it was in the sfio-only code it was not spotted.
* perlapi: May want to use savesharedpv on threaded Win32Karl Williamson2013-12-031-0/+12
| | | | | | Adds a note to savepv (and similar) that on threaded Windows that you may need to use the saveshared version because the memory is deallocated when the thread ends.
* silence -Wformat-nonliteral compiler warningsDavid Mitchell2013-11-281-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to the security risks associated with user-supplied formats being passed to C-level printf() style functions (eg %n), gcc has a -Wformat-nonliteral warning that complains whenever such a function is passed a non-literal format string. This commit silences all such warnings in core and ext/. The main changes are 1) the 'f' (format) flag in embed.fnc is now handled slightly more cleverly. Rather than just applying to functions whose last arg is '...' (and where the format arg is assumed to be the previous arg), it can now handle non-'...' functions: arg checking is disabled, but format checking is sill done: it works by assuming that an arg called 'fmt', 'pat' or 'f' is the format string (and dies if fails to find exactly one such arg). 2) with the new embed.fnc functionally, more functions have been marked with the 'f' flag. When such a function passes its fmt arg onto an inner printf-like function, we simply disable the warning for that call using GCC_DIAG_IGNORE(-Wformat-nonliteral), since we know that the caller must have already checked it. 3) In quite a few places the format string isn't literal, but it *is* constant (e.g. PL_warn_uninit_sv). For those cases, again disable the warning. 4) In pp_formline(), a particular format was was one of several different literal strings depending on circumstances. Rather than assigning this string to a temporary variable, incorporate the ?: branches directly in the function call arg. gcc is clever enough to decide the arg is then always literal.
* fix 'ignoring return value' compiler warningsDavid Mitchell2013-11-241-1/+4
| | | | | | | | | | | Various system functions like write() are marked with the __warn_unused_result__ attribute, which causes an 'ignoring return value' warning to be emitted, even if the function call result is cast to (void). The generic solution seems to be int rc = write(...); PERL_UNUSED_VAR(rc);
* [perl #120543] work around a C++ library bug in VC 2003Tony Cook2013-11-191-1/+1
| | | | | | | VC 2003 makes overloaded versions of ldexp() available when including <math.h> which should only be visible when including <cmath>. The cast ensures the ldexp(double, int) signature is used.
* silence some compiler warningsDavid Mitchell2013-11-131-1/+1
| | | | | | | Actually, most of this commit is adding (void) to various function returns where we know its ok to ignore the return value. This doesn't actually silence the -Wunused-result warning (thanks a bundle gcc), but at least it marks our intentions.
* [perl #119893] avoid waiting on pid 0Tony Cook2013-10-171-6/+8
| | | | | | | | | | | | | | | | | | | When a filehandle is cloned into a standard handle, do_openn() copies the pid from the original handle in PL_fdpid to the standard handle and zeroes the entry for the original handle, so when the original handle was closed Perl_my_pclose() would call wait4pid() with a pid of 0. With v5.19.3-614-gd4c0274 I modified wait4pid(), perl's waitpid/wait4() wrapper, to allow a pid of zero through to the actual system call when available. These combined so that following v5.19.3-614-gd4c0274 in some circumstances closing the original handle would block by calling waitpid(0, ...) or wait4(0, ...), which waits for any child process in the same process group to terminate. This commit changes Perl_my_pclose() to wait for the child only when the stored pid is positive.
* Removed the ifdefs for INCOMPLETE_TAINTSBrian Fraser2013-09-211-2/+0
| | | | | This was added in 5.5/5.6 as a backwards-compatibility measure when taint was extended to happen in more places.
* Replaced the last use of HAS_GNULIBC with __GLIBC__Brian Fraser2013-09-211-1/+1
|
* Removed DUMP_FDS and dump_fds()Brian Fraser2013-09-211-19/+0
| | | | | | If perl was compiled with -DDUMP_FDS, it would define dump_fds and add it to the API, although even then nothing used it. dump_fds() itself was buggy, only checking for fds 0 through 32.
* Remove HAS_64K_LIMITBrian Fraser2013-09-211-23/+2
| | | | | | This was only defined for MSDOS if not using DJGPP. We've long since dropped support for that, so this define and related code can go.
* Use U64_CONST() for the drand48 constants that are larger than 2**32.Nicholas Clark2013-09-181-2/+2
| | | | | Without this the constants are truncated to 32 bits on (at least) HP-UX with 32 bit IVs, which results in some very wrong output from rand().
* [perl #85228] stop $!=EINVAL; waitpid(0,0) from loopingTony Cook2013-09-171-3/+10
|
* Fix the VC6 build on Windows following commit 3be8f09452Steve Hay2013-09-131-0/+2
| | | | | | The VC6 compiler has slightly flaky support for __int64 and chokes on util.c when using the 64-bit implementation of drand48, so switch it to the 32-bit version instead.
* [perl #115928] a consistent (public) rand() implementationTony Cook2013-09-131-0/+100
| | | | | | | | | | | | | | | | Based on Yves's random branch work. This version makes the new random number visible to external modules, for example, List::Util's XS shuffle() implementation. I've also added a 64-bit implementation when HAS_QUAD is true, this should be significantly faster, even on 32-bit CPUs. This is intended to produce exactly the same sequence as the original implementation. The original version of this commit retained the "freebsd" name from Yves's original work for the function and data structure names. I've removed "freebsd" from most function names so the name isn't an issue if we choose to replace the implementation,