summaryrefslogtreecommitdiff
path: root/perl.c
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright yearSteve Hay2017-01-021-2/+2
| | | | (cherry picked from commit f3e2e2629f0f71cdbc3fe0b9102a74a041e7919a)
* (perl #127380) only trace to $PERLIO_DEBUG if -Di is suppliedTony Cook2016-06-081-1/+2
|
* Add locale mutexKarl Williamson2016-04-091-0/+1
| | | | | This adds a new mutex for use in the next commit for use with locale handling.
* Add SILENT_NO_TAINT_SUPPORT to S_Internals_V ()Yves Orton2016-04-061-0/+3
| | | | NO_TAINT_SUPPORT was added in 3b0e4ee2077, but SILENT_NO_TAINT_SUPPORT was overlooked.
* regcomp.c, perl.c: Use 'VOL' not 'volatile'Karl Williamson2016-03-191-1/+1
| | | | | | | I presume that VOL is so perl can at least compile on compilers that lack 'volatile'. (It was added by Larry in 1991 by 352d5a3ab; there were probably a lot more compilers like that back then.) But VOL is used consistently in the core, with these being the two exceptions.
* report an error and fail if we can't flush stdoutTony Cook2016-03-171-0/+13
|
* remove duplicate environment variables from environTony Cook2016-03-011-2/+49
| | | | | | | | | | | | | | | | | | | | | If we see duplicate environment variables while iterating over environ[]: a) make sure we use the same value in %ENV that getenv() returns. Previously on a duplicate, %ENV would have the last entry for the name from environ[], but a typical getenv() would return the first entry. Rather than assuming all getenv() implementations return the first entry explicitly call getenv() to ensure they agree. b) remove duplicate entries from environ Previously if there was a duplicate definition for a name in environ[] setting that name in %ENV could result in an unsafe value being passed to a child process, so ensure environ[] has no duplicates. CVE-2016-2381
* convert CX_PUSHEVAL/POPEVAL to inline fnsDavid Mitchell2016-02-031-1/+1
| | | | | | Replace CX_PUSHEVAL() with cx_pusheval() etc. No functional changes.
* convert CX_PUSH/POP/TOPBLOCK to inline fnsDavid Mitchell2016-02-031-1/+1
| | | | | | Replace CX_PUSHBLOCK() with cx_pushblock() etc. No functional changes.
* offset PL_savestack_max by SS_MAXPUSHDavid Mitchell2016-02-031-2/+6
| | | | | | | | | | | | | | | | The newer SS_ADD macros expect there to always be SS_MAXPUSH slots free on the savestack; so they can push multiple items, then only check once at the end whether stack needs expanding. This commit makes savestack_grow() set PL_savestack_max to SS_MAXPUSH short of what has actually been allocated. This makes the tests to see whether the stack needs growing slightly simpler, i.e. PL_savestack_ix > PL_savestack_max rather than PL_savestack_ix + SS_MAXPUSH > PL_savestack_max
* rename PUSHBLOCK,PUSHSUB etc to CX_PUSHBLOCK etcDavid Mitchell2016-02-031-1/+1
| | | | | | | Earlier all the POPFOO macros were renamed to CX_POPFOO to reflect the changed API (like POPBLOCK no longer decremented cxstack_ix). Now rename the PUSH ones for consistency.
* PUSHEVAL: make retop a parameterDavid Mitchell2016-02-031-1/+1
| | | | | | Rather than doing cx->blk_eval.retop = NULL in PUSHEVAL, then relying on the caller to subsequently change it to something more useful, make it an arg to PUSHEVAL.
* rename POPFOO() to CX_POPFOO()David Mitchell2016-02-031-1/+1
| | | | | | | | | | | | | | | | Rename all the context-popping macros such as POPBLOCK and POPSUB, by giving them a CX_ prefix. (Do TOPBLOCK too). This is principally to deliberately break any existing non-core use of these non-API macros, as their behaviour has changed in this branch. In particular, POPBLOCK(cx) no longer decrements the cxt stack pointer nor sets cx; instead, cx is now expected to already point to the stack frame which POPBLOCK should process. At the same time, giving them a CX_ prefix makes it clearer that these are all part of a family of macros that manipulate the context stack. The PUSHFOO() macros will be renamed in a later commit.
* restore PL_tmps_floor on exitDavid Mitchell2016-02-031-1/+4
| | | | | | | | | | A couple of places were expecting dounwind(-1); LEAVE_SCOPE(0); to restore PL_tmps_floor, since its old value was saved on the savestack. Since that's now stored in the context struct instead, do a POPBLOCK(&cxstack[0]). This problem only showed up on 'make test' rather than 'make test_harness', since only the former sets PERL_DESTRUCT_LEVEL.
* add CX_CUR() macroDavid Mitchell2016-02-031-1/+1
| | | | | | This is simply #define CX_CUR() (&cxstack[cxstack_ix])
* call_sv(), fold_const(): different CX pop testDavid Mitchell2016-02-031-3/+8
| | | | | | | | | | | | | | | | | | Perl_call_sv() and S_fold_constants() both have similar code that: pushes an EVAL context, does a JMPENV_PUSH() and CALLRUNOPS(), then optionally pops the EVAL context. The optionally part depends on whether what's doing the dying has already popped the context before long-jumping. Currently the decision on whether to pop is based on whether the scope stack has already been popped. This commit changes that to whether the context stack has already been popped, since shortly we're going to change eval contexts so that the old savestack_ix is stored in the CX struct rather than on the scope stack. I ran this code with some asserts that the two conditions were identical, and nothing failed.
* Fix umask for mkstemp(3) callsNiko Tyni2016-01-291-1/+1
| | | | | | | | | | | | | | | | | | With commit v5.21.0-67-g60f7fc1, perl started setting umask to 0600 before calling mkstemp(3), and then restoring it afterwards. This is wrong as it tells open(2) to strip the owner read and write bits from the given mode before applying it, rather than the intended negation of leaving only those bits in place. On modern systems which call open(2) with mode 0600 in mkstemp(3), this clears all the created temporary file permissions. However, any systems that use mode 0666 in mkstemp(3) (like ancient versions of glibc) now create a file with permissions 0066, leaving world read and write permission regardless of current umask. Using umask 0177 instead fixes this. Bug: https://rt.perl.org/Ticket/Display.html?id=127322
* Use vmstrnenv() to look up PERL5LIB/PERLLIB on VMS.Craig A. Berry2016-01-251-5/+5
| | | | | | | | | | | | | | | We have, for a long time, only considered logical names when looking for values of PERL5LIB. However, this makes us miss values stored in the environ array (such as when happens when Perl is invoked from bash) or as DCL symbols. So make looking up PERL5LIB and PERLLIB use the lower level routine that will look up values using the same search order as all other environment handling in Perl, while still handling a list of paths as a search list logical if that's where the value is stored. N.B. There is no change to the default path separator here, only to lookup method.
* updating copyright to 2016Stevan Little2016-01-201-2/+2
|
* Add qr/\b{lb}/Karl Williamson2016-01-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the final Unicode boundary type previously missing from core Perl: the LineBreak one. This feature is already available in the Unicode::LineBreak module, but I've been told that there are portability and some other issues with that module. What's added here is a light-weight version that is lacking the customizable features of the module. This implements the default Line Breaking algorithm, but with the customizations that Unicode is expecting everybody to add, as their test file tests for them. In other words, this passes Unicode's fairly extensive furnished tests, but wouldn't if it didn't include certain customizations specified by Unicode beyond the basic algorithm. The implementation uses a look-up table of the characters surrounding a boundary to see if it is a suitable place to break a line. In a few cases, context needs to be taken into account, so there is code in addition to the lookup table to handle those. This should meet the needs for line breaking of many applications, without having to load the module. The algorithm is somewhat independent of the Unicode version, just like the other boundary types. Only if new rules are added, or existing ones modified is there need to go in and change this code. Otherwise, running regen/mk_invlists.pl should be sufficient when a new Unicode release is done to keep it up-to-date, again like the other Unicode boundary types.
* silence compiler warnings using INCMARK/POPMARKDavid Mitchell2015-11-191-2/+2
| | | | | | | | | | v5.23.3-305-g6cae08a introduced debugging variants of INCMARK/POPMARK, and replaced a number of "PL_markstack_ptr--;" with "POPMARK;" etc. This spews a bunch of "value computed is not used" warnings; so add some "(void)"s. Also indent the new definitions of INCMARK/POPMARK correctly.
* MARK -Ds debuggingReini Urban2015-11-101-2/+2
| | | | | display the MARK arity and pointers with MARK macros. assert on markptr underflow.
* Allow overriding the compile time in "perl -V" outputNiko Tyni2015-11-031-7/+12
| | | | | | | | | | | | | | The C preprocessor macros __DATE__ and __TIME__ embed the compile time into the binary for the purposes of "perl -V" output. This makes the build unreproducible: compiling the same source with the same toolchain cannot be made to yield bitwise identical binaries and other generated files. The compile time can now be overridden with the PERL_BUILD_DATE macro. Bug: https://rt.perl.org/Ticket/Display.html?id=125830 Bug-Debian: https://bugs.debian.org/774422 Patch-Name: debian/do-not-record-build-date.diff
* Revert "Remove unused filesystem stat symbols."Jarkko Hietaniemi2015-10-301-0/+8
| | | | | | | | | | | This reverts commit 821805a244cacd9869331999cd53407f3323206a. What's out, is out. perl #107904 Filesys-Df perl #108189 Filesys-DfPortable perl #108191 Filesys-Statvfs perl #126368 Filesys-DfPortable
* [perl #126242] make the constant hash seeds unsigned char *Tony Cook2015-10-141-2/+2
| | | | | ...to prevent warnings on most C compilers and build failures on C++ compilers for -DNO_HASH_SEED builds.
* Perl_call_sv move EXTEND into branch that needs itDaniel Dragan2015-10-131-5/+3
| | | | | | | | | | | | | | If we aren't manipulating the stack, dont fetch it, check and possibly extend it. There is a slight chance this EXTEND was covering up missing EXTENDs somewhere else in Perl core or CPAN C code, if future bisects or valgrind reports show that this EXTEND by 1 must always be done, this patch can be reverted. pp_method_named contains a EXTEND/XPUSH* call, pp_entersub requires 1 arg on stack so, both sides of the "if (!(flags & G_METHOD_NAMED))" test will in theory make sure there is 1 free slot on the stack on entry to a SUB or XSUB. See also http://www.nntp.perl.org/group/perl.perl5.porters/2015/09/msg231329.html
* remove repeated PL_stack_sp derefs in Perl_eval_sv/Perl_call_svDaniel Dragan2015-10-131-8/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reduce scope of local SP and remove excessive reads and writes to PL_stack_sp in Perl_eval_sv/Perl_call_sv. EXTEND macro refetches the possibly realloced SP on its own, Perl_stack_grow returns the new SP as a retval and therefore in a register. By using PL_stack_sp instead of Perl_stack_grow, an extra redundant mem read is done. Also dont keep SP around for long periods unused, it wastes a C stack slot or non-vol reg and makes the callframe bigger. The EXTEND could be placed in the !(flags & G_METHOD_NAMED) branch, but that will be done in another patch for bisectability. VC 2003 -O1 machine code sizes of the functions Perl_eval_sv before 0x28a after 0x286 Perl_call_sv before 0x3cd after 0x3cb The savings look small since in x86 "*var+=4" and "var+=4" are the same number of bytes to encode the instruction, only the mod R/M bitfield vals are different. RISC CPUs benefit more from this patch. commit c106c2be8b "G_METHOD_NAMED flag for call_method and call_sv" added skipping the push SV onto stack The EXTEND and PL_stack_sp direct manipulation code is from commit a0d0e21ea6 "perl 5.000". The reason is unknown why it did "SV** sp = stack_sp;" and later "EXTEND(stack_sp, 1);" instead of using SP, since EXTEND at that time, and to this day requires C auto sp be in scope.
* add Win32 USE_NO_REGISTRY build optionDaniel Dragan2015-10-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -the first arg of win32_get_privlib is not used if the registry is not queried, create a macro to allow the arg to drop out on WIN32_NO_REGISTRY builds for efficiency and not to have unused C litteral strings in the binary -This patch changes the ABI of PerlEnv_lib_path/PerlEnvLibPath/win32_get_privlib between USE_NO_REGISTRY and no USE_NO_REGISTRY. Since win32_get_privlib is not exported from perl523.dll, assume it and PerlEnv_lib_path are not public API, note technically PerlEnv_lib_path will be callable only on PERL_IMPLICIT_SYS builds, on no PERL_IMPLICIT_SYS builds it will fail at link time since win32_get_privlib isnt exported. Therefore place it in non-[affecting]-binary compatibility even though it does affect binary compatibility. -delay load advapi32.dll to save startup time (loading the DLL and the DLL calling its initializers in DllMain) and one 4 KB memory page for advapi32's .data section (doing "perl -E"sleep 100" on WinXP shows advapi32 has a 20KB long .data section, first 4 KB are unique to the process, the remaining 16KB are COW shared between processes according to vmmap tool), putting a DebugBreak() in pp_getlogin and doing a "nmake all" shows miniperl never calls getlogin during the build process. An nmake test shows only ext/POSIX/t/wrappers.t and lib/warnings.t execute pp_getlogin. Keeping advapi32.dll out of the perl process requires removing comctl32.dll, since comctrl32.dll loads advapi32.dll, from perl which I always do as a custom patch. filed as [perl #123658] XXXXXXXXXXXXXXXXXXXXXXX
* partial PL_statbuf removalDaniel Dragan2015-10-081-8/+5
| | | | | | | | | | | | | | | | Perl_nextargv has to have access to the Stat_t that is written to inside S_openn_cleanup or else run/switches.t, io/argv.t, io/inplace.t, and io/iprefix.t will fail. Removing the uses of PL_statbuf that are using PL_statbuf due to historical reason, and not using PL_statbuf to pass data between different funcs/different callstacks. This patch makes it easier to remove PL_statbuf in the future since the number uses of it has been reduced. -in Perl_apply move SETERRNO before tot--; so the branch can be combined with other "tot--;" branches by CC optmizer -combine 2 Perl_croak(aTHX_ "Illegal suidscript"); statements in S_validate_suid to make code look simpler, drop my_perl arg for space efficiency on threads of rarely executed code
* Remove unused filesystem stat symbols.Jarkko Hietaniemi2015-10-021-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | d_fs_data_s HAS_STRUCT_FS_DATA d_fstatfs HAS_FSTATFS d_fstatvfs HAS_FSTATVFS d_getfsstat HAS_GETFSSTAT d_getmnt HAS_GETMNT d_getmntent HAS_GETMNTENT d_hasmntopt HAS_HASMNTOPT d_statfs_f_flags HAS_STRUCT_STATFS_F_FLAGS d_statfs_s HAS_STRUCT_STATFS d_ustat HAS_USTAT i_mntent I_MNTENT i_sysmount I_SYS_MOUNT i_sysstatfs I_SYS_STATFS i_sysstatvfs I_SYS_STATVFS i_sysvfs I_SYS_VFS i_ustat I_USTAT Unused by the Perl core. As far as I can remember I added these scans long ago, for some purpose (df(1) kind of APIs?) but whatever it was, it obviously hasn't exactly caught fire in the last 15 years. Some rare uses of these APIs (not these defines, but e.g. statfs) in CPAN (like the Quota module), but those seem to do their own configuration.
* amigaos4: use #ifdef/ifndef __amigaos4__ when feasibleAndy Broad2015-09-161-1/+1
|
* amigaos4: translate $^X to unix styleAndy Broad2015-09-051-0/+8
|
* Change to use UVCHR_SKIP over UNI_SKIPKarl Williamson2015-09-041-2/+2
| | | | | | | | | | UNI_SKIP is somewhat ambiguous. Perl has long used 'uvchr' as part of a name to mean the unsigned values using the native character set plus Unicode values for those above 255. This also changes two calls (one in dquote_static.c and one in dquote_inline.h) to use UVCHR_SKIP; they should not have been OFFUNI, as they are dealing with native values.
* Various pods: Add C<> around many typed-as-is thingsKarl Williamson2015-09-031-3/+3
| | | | Removes 'the' in front of parameter names in some instances.
* Explicitly use and check for FD_CLOEXEC.Jarkko Hietaniemi2015-08-261-2/+2
| | | | | | | | This may break places which have the FD_CLOEXEC functionality but do not have the FD_CLOEXEC define. In any case, using a boolean for the F_SETFD flag is icky. Using an explicit 1 is also dubious.
* [perl #120826] - Fix documentation nit (thanks Eric Brine.)Matthew Horsfall2015-08-171-1/+1
|
* [perl #120826] correct documentation of sv parameter of call_sv()Tony Cook2015-08-051-2/+16
|
* xs_boot_epilog (Xp): change ax from U32 to I32Reini Urban2015-08-031-1/+1
| | | | we need to match the declaration of ax
* mktables: Add handling of WB and SB for early UnicodesKarl Williamson2015-07-281-2/+2
| | | | | | | This allows \b{wb} and \b{sb} to work on all Unicode releases. The huge number of differences in charclass_invlists.h is only because the names of the SB and WB tables change, and the code automatically re-alphabetizes things.
* mktables: Fix GCB to work on early UnicodesKarl Williamson2015-07-281-1/+1
| | | | | | | | The GCB property was not properly being generated in early Unicode releases. The huge commit diff is due solely to the fact that the name changes of this property so it is sure to not be accessible outside the perl core, and the property tables are automatically resorted alphabetically.
* Remove NEW_ from PERL_NEW_COPY_ON_WRITEFather Chrysostomos2015-06-291-3/+3
|
* refactor win32_get_*lib() funcs to match rest of PERL_IMPLICIT_SYS APIDaniel Dragan2015-06-031-3/+3
| | | | | | | | | | | | | | | | | | The front end of PERL_IMPLICIT_SYS is PerlEnv_*/PerlSock_*/PerlProc_*/etc macros. These are either macroed to C vtable calls when PERL_IMPLICIT_SYS is on, or to the backend raw win32_*() functions when PERL_IMPLICIT_SYS is off. win32_get_*() were not following this convention. All this code looks like a hack as if someone didn't have perms to edit perl.c, but they did have perms to edit /win32, so they devise a scheme of hooking "unhooked" win32_get_*() functions with win32.h macros for win32_get_*() to call the Perl*() virutalization macros, and rename the original function bodies in win32.c to g_win32_get_*() as to not make a macro loop. Undo all of this hack by having perl.c call correct PerlEnv_* macro. This refactoring will be useful for a future patch in #123658 to disable win32 registry lookups.
* remove obsolete VOL in S_parse_bodyDaniel Dragan2015-06-021-1/+1
| | | | | | | | commit 312caa8e97 removed dJMPENV from perl_parse_body (former perl_parse) when it created perl_parse_body and perl_parse kept the dJMPENV, but this commit forgot to remove the VOL tag on var dosearch. Since the VOL is only required when the function has a setjmp in it, and this function doesn't have a setjmp in it anymore, remove the VOL tag.
* Replace common Emacs file-local variables with dir-localsDagfinn Ilmari Mannsåker2015-03-221-6/+0
| | | | | | | | | | | | | | | | An empty cpan/.dir-locals.el stops Emacs using the core defaults for code imported from CPAN. Committer's work: To keep t/porting/cmp_version.t and t/porting/utils.t happy, $VERSION needed to be incremented in many files, including throughout dist/PathTools. perldelta entry for module updates. Add two Emacs control files to MANIFEST; re-sort MANIFEST. For: RT #124119.
* PL_custom_op{s,_names,_descs} should be set to NULL in perl_destruct().Nicholas Clark2015-03-171-0/+7
| | | | | | | | | | | | | | | Otherwise SEGVs and other jollity can happen if the interpreter is created a second (or subsequent) time, and modules attempt to register custom OPs (using either the old or new approaches). These appear to have been bugs since the relevant code was introduced (new approach in v5.14.0, old approach in v5.8.0) This probably only affects mod_perl built against a perl without ithreads, which makes it unlikely that many folks hit it with OS distributions. You'd need to (at least) be building your own perl, using mod_perl, and using a module that uses custom OPs.
* don't test non-null argsDavid Mitchell2015-03-111-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For lots of core functions: if a function parameter has been declared NN in embed.fnc, don't test for nullness at the start of the function, i.e. eliminate code like if (!foo) ... On debugging builds the test is redundant, as the PERL_ARGS_ASSERT_FOO at the start of the function will already have croaked. On optimised builds, it will skip the check (and so be slightly faster), but if actually passed a null arg, will now crash with a null-deref SEGV rather than doing whatever the check used to do (e.g. croak, or silently return and let the caller's code logic to go awry). But hopefully this should never happen as such instances will already have been detected on debugging builds. It also has the advantage of shutting up recent clangs which spew forth lots of stuff like: sv.c:6308:10: warning: nonnull parameter 'bigstr' will evaluate to 'true' on first encounter [-Wpointer-bool-conversion] if (!bigstr) The only exception was in dump.c, where rather than skipping the null test, I instead changed the function def in embed.fnc to allow a null arg, on the basis that dump functions are often used for debugging (where pointers may unexpectedly become NULL) and it's better there to display that this item is null than to SEGV. See the p5p thread starting at 20150224112829.GG28599@iabyn.com.
* [perl #123814] replace grok_atou with grok_atoUVHugo van der Sanden2015-03-091-13/+21
| | | | | | | | | | | | Some questions and loose ends: XXX gv.c:S_gv_magicalize - why are we using SSize_t for paren? XXX mg.c:Perl_magic_set - need appopriate error handling for $) XXX regcomp.c:S_reg - need to check if we do the right thing if parno was not grokked Perl_get_debug_opts should probably return something unsigned; not sure if that's something we can change.
* perl.c: Don't read possibly zapped memoryKarl Williamson2015-03-091-0/+4
| | | | | | | | | | | | | See https://rt.perl.org/Ticket/Display.html?id=123748 The return of getenv() is a pointer to static storage which can legally be overwritten at any time by other calls to access the environment, even even another getenv(). (What actually happens varies from platform to platform.) Results of getenv() therefore either have to be acted on immediately or copied to a safe area. This commit does the latter for this call in perl.c. The static area was being held on to even into the function call moreswitches() which does environmen handling, so was vulnerable to this bug.
* Skip PL_warn_locale use unless compiled inKarl Williamson2015-03-071-0/+4
| | | | | | | The use of this variable was inconsistent. It was not dup'ed on thread cloning unless LC_CTYPE is being used, but elsewhere it was. This led to segfaults on threaded builds. Now it isn't touched anywhere unless LC_CTYPE is used.
* sprinkle NOTREACHED and FALLTHROUGHDavid Mitchell2015-03-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | Coverity complains bitterly about many switch statements in lots of files. Many of these are of the form: case FOO: ... goto baz; case BAR: .... and something as smart as Coverity shouldn't really be complaining about a missing 'break' when the last statement of the previous branch is an unconditional goto/return/continue. But I've shoved in a bunch of 'NOTREACHED' to hopefully shut it up. Missing 'FALLTHROUGH' comments were more reasonable, and I've added them where appropriate. The only confusing one was cx_dup(), where the various CXt_LOOP_ branches all fell through to the next one, and it took a while to figure out that those weren't bugs.