summaryrefslogtreecommitdiff
path: root/perl.c
Commit message (Collapse)AuthorAgeFilesLines
...
* hv.* - disable unshared keys except when requestedYves Orton2022-04-191-0/+3
| | | | | | | | | This disables the new unshared hash key logic by default. People who wish to try it out can enable it at build time with -DPERL_USE_UNSHARED_KEYS_IN_LARGE_HASHES in the configure process.
* perl.c: www.perl.org uses httpsRichard Leach2022-03-131-1/+1
|
* hv.c - rework PL_hash_rand_bits update logic, add tests, -Dh debug modeYves Orton2022-03-101-24/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | This moves all run time mutations of PL_hash_rand_bits into a set of macros which allow us to debug what is happening. It also moves away from our poor mans RNG based on mixing in various sources of data as we go and switches to using an XORSHIFT RNG for generating the random bits. This particular RNG is very efficient, using three xor operations and three shift operations, so it shouldn't hurt us to use it. As a bonus it also removes the conditional logic involved, as we use seed() to initialize things at the very beginning when we are running under RANDOMIZE mode, which should fix any problems with running on platforms that do not use process space randomization like cygwin. It adds support for -Dh under DEBUGGING to allow introspection of the the state of PL_hash_rand_bits and source and cause of changes to it. With -Dhv you can also get an idea of the keys which are triggering these mutations as well. -Dh has also been changed to imply PERL_HASH_SEED_DEBUG as a convenience. This goes alongside a new test, based on one from Nicholas R (atoomic) to test that the various PERL_PERTURB_KEYS options behave as expected and that 1 bit mutations of the seed actually *do* affect the key order and hashing of our strings. The test is run many times to ensure that it passes under many different randomly generated hash seeds. Parts of this test would fail without the preceding commit to this one adjusting how SBOX32 is initialized.
* perl.c: Remove run time docs and redundant support for -DHYves Orton2022-03-051-2/+7
| | | | | | | | | | | In 2017 in fcd573e77ec68fbe3936ac1381654581fba8a64f Dave Mitchell removed support for the -DH flag but missed this. Part of the -D options parsing is positionally sensitive, so in order to be able to remove the 'H' option entirely I had to use a placeholder character, and I chose '?'. This is because it is not isWORDCHAR(), which means the preceding logic prevents it from being chosen anyway, and thus it should be safe.
* perl.c: zero stacks on creationYves Orton2022-03-021-5/+5
| | | | | | | I think not initializing these to zero is a false economy, Felipe Gasper brought this up that it made debugging issues with the stack confusing. We only do this once per process and zeroing memory is prety cheap so it make sense to me to zero the stacks on startup.
* implement a new command-line flag, -gTomasz Konojacki2022-02-191-0/+6
| | | | | It's a simpler alias for -0777. It was proposed in RFC-0011: https://github.com/Perl/RFCs/blob/master/rfcs/rfc0011.md
* Remove PERL_BOOL_AS_CHAR uses; always define HAS_BOOLKarl Williamson2022-02-061-3/+0
| | | | | | | | | | Now that C99 is required, bool is always defined, so HAS_BOOL should also always be defined. PERL_BOOL_AS_CHAR was used to workaround problems when no bool type existed, so it is obsolete, and in fact perl won't compile if PERL_BOOL_AS_CHAR is #defined. So remove it completely from being looked at.
* Update Perl copyright for 2022Nicolas R2022-01-201-3/+3
|
* Add option '-?' as a synonym to -hKarl Williamson2021-12-241-0/+4
| | | | | | | -? is a common paradigm for finding the usage of a program. Prior to this commit, doing so on perl would tell you it is illegal and suggest -h. This commit allows someone using this paradigm to skip the second step
* Add a builtin:: namespace, with true/false/isboolPaul "LeoNerd" Evans2021-11-291-0/+1
| | | | | | | | This finishes the perl-visible API required for RFC 0008 https://github.com/Perl/RFCs/blob/master/rfcs/rfc0008.md It also begins the "builtin::" namespace of RFC 0009 https://github.com/Perl/RFCs/blob/master/rfcs/rfc0009.md
* newSVpvn_flags(x, .. ,SVs_TEMP) more efficient than sv_2mortal(newSVpv(x,0))Richard Leach2021-11-291-3/+6
|
* Remove DOS/DJGPP supportDagfinn Ilmari Mannsåker2021-11-021-20/+2
| | | | | | DJGPP is a port of the GNU toolchain to 32-bit x86 systems running DOS. The last known attempt to build Perl on it was on 5.20, which only got as far as building miniperl.
* Remove NetWare supportDagfinn Ilmari Mannsåker2021-10-081-17/+7
| | | | The build has been broken since 2009.
* Replace "Grandfather" with a description of the relevant heuristicNicholas Clark2021-09-281-1/+10
| | | | | | | | | | In April 2003 commit f2095865e3489f4e: Noted by Nat: -0 didn't work that well with Unicode. added support for passing hexadecimal to the -0 option. As '-0' has an optional argument, the chosen syntax for hex was ambiguous with '-0' clustered with an '-x' option with an argument, so the heuristic described here was implemented.
* perl_alloc_using() should use ->pCallocNicholas Clark2021-09-281-2/+1
| | | | | | | | Use ->pCalloc instead of ->pMalloc followed by Zero() This commit is analogous to the change in perl_alloc() in the previous commit - the order of S_init_tls_and_interp() and Zero() can be swapped, at which point the change to use "calloc" is obvious.
* No need to wrap INIT_TRACK_MEMPOOL with #ifdef PERL_TRACK_MEMPOOLNicholas Clark2021-09-281-2/+0
| | | | | | | `INIT_TRACK_MEMPOOL` is defined as a no-op if `PERL_TRACK_MEMPOOL` is not defined, so no need to wrap it in `#ifdef`. Spotted by Ilmari.
* perl_alloc() wants zeroed memory so should use calloc()Nicholas Clark2021-09-281-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | The previous code 1) allocated memory with PerlMem_malloc() 2) passed the pointer to S_init_tls_and_interp() 3) called Zero() or ZeroD() 4) optionally invoked INIT_TRACK_MEMPOOL() 5) returned the pointer ZeroD() and Zero() are equivalent, apart from the return value of the expression. The layers of functions and macros obscured what what was actually happening, and what the ordering dependencies are: * S_init_tls_and_interp() uses only the address of the pointer * Zero() zeros the memory * Only INIT_TRACK_MEMPOOL() touches the contents * all the "memory wrap" macros inside the other macros can't "trigger" Hence the order of Zero() and S_init_tls_and_interp() can be swapped, at which point Zero() immediately follows malloc(), meaning that the two should be be replaced with calloc(). This simplifies the function considerably.
* Use sv_inc() for the env de-dup hash in S_init_postdump_symbols().Nicholas Clark2021-08-231-4/+5
| | | | This replaces an hv_exists/hv_store pair with a single LVALUE hv_fetch.
* Comment about some subtleties in S_init_postdump_symbols().Nicholas Clark2021-08-231-0/+11
|
* Move some variables in S_init_postdump_symbols() to a tighter scope.Nicholas Clark2021-08-231-10/+11
|
* Pre-size the %ENV hash before populating it from environ.Nicholas Clark2021-08-231-1/+20
| | | | | Also use HvTOTALKEYS() instead of HvKEYS(), as the latter makes a check for placeholders, which here cannot make a difference.
* replace all instances of PERL_IMPLICIT_CONTEXT with MULTIPLICITYTomasz Konojacki2021-06-091-2/+2
| | | | | | | | | | | | Since the removal of PERL_OBJECT (acfe0abcedaf592fb4b9cb69ce3468308ae99d91) PERL_IMPLICIT_CONTEXT and MULTIPLICITY have been synonymous and they're being used interchangeably. To simplify the code, this commit replaces all instances of PERL_IMPLICIT_CONTEXT with MULTIPLICITY. PERL_IMPLICIT_CONTEXT will stay defined for compatibility with XS modules.
* Rename G_ARRAY to G_LIST; provide back-compat when not(PERL_CORE)Paul "LeoNerd" Evans2021-06-021-2/+2
|
* Base *.[ch] files: Replace leading tabs with blanksMichael G Schwern2021-05-311-1915/+1915
| | | | | | | This is a rebasing by @khw of part of GH #18792, which I needed to get in now to proceed with other commits. It also strips trailing white space from the affected files.
* gh18842: fix a pair of sprintf format warningsHugo van der Sanden2021-05-311-2/+2
| | | | | The format is '%s', so it is not appropriate to wrap the char * arguments in SVfARG().
* Bump copyright to 2021 in perl.c and README.Steve Hay2021-01-071-2/+3
| | | | | | Check that porting/copyright.t is passing when run with --now: ../perl -I../lib porting/copyright.t --now
* Consolidate and document all get_cvFOO() variantsKarl Williamson2020-12-131-5/+12
|
* Remove empty "#ifdef"sTom Hukins2020-12-081-2/+0
|
* perl - update usage data to match perlrunDan Book2020-11-231-28/+28
|
* autodoc.pl: Enhance apidoc_section featureKarl Williamson2020-11-061-7/+7
| | | | | | | | | | | This feature allows documentation destined for perlapi or perlintern to be split into sections of related functions, no matter where the documentation source is. Prior to this commit the line had to contain the exact text of the title of the section. Now it can be a $variable name that autodoc.pl expands to the title. It still has to be an exact match for the variable in autodoc, but now, the expanded text can be changed in autodoc alone, without other files needing to be updated at the same time.
* Non-Configure code required to implement a strict by default optionTodd Rinaldo2020-09-151-0/+4
|
* Reorganize perlapiKarl Williamson2020-09-041-6/+6
| | | | | This uses a new organization of sections that I came up with. I asked for comments on p5p, but there were none.
* Change some =head1 to apidoc_section linesKarl Williamson2020-09-041-1/+1
| | | | | apidoc_section is slightly favored over head1, as it is known only to autodoc, and can't be confused with real pod.
* perl.c: Convert to use av_count()Karl Williamson2020-08-191-2/+2
|
* Remove PL_appctx and PL_timesbase interpreter variablesDagfinn Ilmari Mannsåker2020-07-201-7/+0
| | | | These were only ever needed by Symbian.
* Remove use of dVAR in coreDagfinn Ilmari Mannsåker2020-07-201-15/+0
| | | | | It only does anything under PERL_GLOBAL_STRUCT, which is gone. Keep the dNOOP defintion for CPAN back-compat
* Remove PERL_GLOBAL_STRUCTDagfinn Ilmari Mannsåker2020-07-201-3/+0
| | | | | | | | This was originally added for MinGW, which no longer needs it, and only still used by Symbian, which is now removed. This also leaves perlapi.[ch] empty, but we keep the header for CPAN backwards compatibility.
* Remove Symbian portDagfinn Ilmari Mannsåker2020-07-201-9/+2
| | | | | Also eliminate USE_HEAP_INSTEAD_OF_STACK and SETSOCKOPT_OPTION_VALUE_T, since Symbian was the only user of those.
* Make PL_utf8_foldclosures interpreter levelKarl Williamson2020-06-021-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | This resolves #17774. This ticket is because the fixes in GH #17154 failed to get every case, leaving this one outlier to be fixed by this commit. The text in https://github.com/Perl/perl5/issues/17154 gives extensive details as to the problem. But briefly, in an attempt to speed up interpreter cloning, I moved certain SVs from interpreter level to global level in e80a0113c4a8036dfb22aec44d0a9feb65d36fed (v5.27.11, March 2018). This was doable, we thought, because the content of these SVs is constant throughout the life of the program, so no need to copy them when cloning a new interpreter or thread. However when an interpreter exits, all its SVs get cleaned up, which caused these to become garbage in applications where another interpreter remains running. This circumstance is rare enough that the bug wasn't reported until September 2019, #17154. I made an initial attempt to fix the problem, and closed that ticket, but I overlooked one of the variables, which was reported in #17774, which this commit addresses. Effectively the behavior is reverted to the way it was before e80a0113c4a8036dfb22aec44d0a9feb65d36fed.
* Fix a bunch of repeated-word typosDagfinn Ilmari Mannsåker2020-05-221-1/+1
| | | | | Mostly in comments and docs, but some in diagnostic messages and one case of 'or die die'.
* fixup to free_and_set_cop_warnings()David Mitchell2020-03-201-3/+3
| | | | | | | | | | | | | | | | | | | v5.31.9-156-g94c8b9c1f0 introduced the free_and_set_cop_warnings() macro. It's first argument expects a COP rather than a COP*. Its usage in S_restore_cop_warnings(() is to modify PL_cucop, but in order to pass a COP rather than a COP*, the original commit made a local copy of PL_curcop and ended up inadvertently updating the copy instead. This commit changes the maco so it expects a COP*, and updates the bulk of its callers to use &PL_compiling rather than PL_compiling, and fixes up S_restore_cop_warnings(). The symptoms were ASAN failures in a few test scripts including uni/parser.t and ext/XS-APItest/t/handy0*.t. (The S_restore_cop_warnings() function was only used by Perl__force_out_malformed_utf8_message(), so didn't cause many issues outside of test scripts which forced such "malformed "errors).
* Add macro to free and set cop_warningsNicolas R2020-03-161-9/+3
| | | | | This is avoiding the boilerplate to free the cop_warning string when setting it.
* Add thread safety to some environment accessesKarl Williamson2020-03-111-4/+0
| | | | | | | | | | | | | | | | | | The previous commit added a mutex specifically for protecting against simultaneous accesses of the environment. This commit changes the normal getenv, putenv, and clearenv functions to use it, to avoid races. This makes the code simpler in places where we've gotten burned and added stuff to avoid races. Other places where we haven't known we were getting burned could have existed until now. Now that comes automatically, and we can remove the special cases we earlier stumbled over. getenv() returns a pointer to static memory, which can be overwritten at any moment from another thread, or even another getenv from the same thread. This commit changes the accesses to be under control of a mutex, and in the case of getenv, a mortalized copy is created so that there is no possible race.
* Add mutex for accessing ENVKarl Williamson2020-03-111-0/+1
|
* pp_i_modulo(): remove workaround for ancient glibc bugDagfinn Ilmari Mannsåker2020-02-051-22/+0
| | | | | | | | | Old glibc versions had a buggy modulo implementation for 64 bit integers on 32-bit architectures. This was fixed in glibc 2.3, released in 2002 (the version check in the code is overly cautious). Removing the alternate PP function support is left for the next commit, in case we need to resurrect it in future.
* Bump copyright to 2020 in perl.c and README.Nicolas R2020-01-021-2/+2
| | | | | | | check that porting/copyright.t is passing when run with --now ../perl -I../lib porting/copyright.t --now
* Add memCHRs() macro and use itKarl Williamson2019-12-181-1/+1
| | | | | | | This replaces strchr("list", c) calls throughout the core. They don't work properly when 'c' is a NUL, returning the position of the terminating NUL in "list" instead of failure. This could lead to segfaults or even security issues.
* Revert "Move PL_check to the interp vars to fix threading issues"Tony Cook2019-12-161-1/+0
| | | | | and the associated commits, at least until a way to make wrap_op_checker() work is available.
* Move PL_check to the interp vars to fix threading issuesStefan Seifert2019-12-121-0/+1
| | | | Fixes issue #14816
* Note that G_RETHROW is documentedKarl Williamson2019-12-111-0/+1
| | | | This is for Devel::PPPort.