summaryrefslogtreecommitdiff
path: root/embed.fnc
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2014-02-11 20:27:30 -0700
committerKarl Williamson <public@khwilliamson.com>2014-02-17 11:26:41 -0700
commit7dcac5f6a5195002b55c935ee1d67f67e1df280b (patch)
treed60f6153eafb425e1accc696cc641460caec6156 /embed.fnc
parent55f616c39553c61edd12406823d815451f74c97f (diff)
downloadperl-7dcac5f6a5195002b55c935ee1d67f67e1df280b.tar.gz
regcomp.c: Fix some alignment problems
The bracketed character class (e.g. /[abc]/) in regular expression patterns is implemented as an ANYOF regnode. There are several different structs used for these, each a superset of the next smaller size, with extra fields tacked on to its end. Bits in the part common to all of them are set to indicate which size this particular instance is. Several functions in regcomp.c take the largest of these as a formal parameter, even though a smaller one may actually be passed. This avoids the need to have casts to access the optional fields, but the code needs to be careful to check the common part bits before trying to access a portion that may not actually be present. This practice dates to at least Perl v5.6.2. It turns out that there is further a problem with this if the tacked-on fields require a stricter alignment than the common fields. The code in the functions may assume that the actual parameter has suitable alignment, which may not be the case. Some months ago I added some extra optional pointer fields, which have stricter alignment requirements on 64-bit machines than the common portion, but no apparent problems ensued. Then, I changed things slightly, so that the gcc compiler on HP machines found an optimization possibility whose use required the proper alignment, which wasn't present, and bus errors started happening there. Tony Cook diagnosed the problem. A summary of his work can be found at http://markmail.org/message/hee5zyah7rb62c72 This commit changes the formal parameter to the smallest ANYOF struct, and uses casts to acess the optional portions. I don't know how common the coding style formerly used in regcomp.c is, but it is dangerous and can lead to unrelated changes causing errors. This commit should enable gcc builds to complete on the HP gcc smokers (previously miniperl built, but crashed in building the rest of perl), but we're not sure because unrelated header issues on the gcc on the machine that we have access to prevent blead from fully compiling there. There remain alignment bugs which will cause the tests to fail there, as the appended pointer field needs to have strict alignment on that platform, but when the regnodes are allocated alignment isn't done. I am working on fixing those.
Diffstat (limited to 'embed.fnc')
-rw-r--r--embed.fnc4
1 files changed, 2 insertions, 2 deletions
diff --git a/embed.fnc b/embed.fnc
index e9795a7cb2..6856092477 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -2088,11 +2088,11 @@ EsR |int |ssc_is_cp_posixl_init|NN const RExC_state_t *pRExC_state \
|NN const regnode_ssc *ssc
Es |void |ssc_and |NN const RExC_state_t *pRExC_state \
|NN regnode_ssc *ssc \
- |NN const regnode_ssc *and_with
+ |NN const regnode_charclass *and_with
Esn |void |ssc_flags_and |NN regnode_ssc *ssc|const U8 and_with
Es |void |ssc_or |NN const RExC_state_t *pRExC_state \
|NN regnode_ssc *ssc \
- |NN const regnode_ssc *or_with
+ |NN const regnode_charclass *or_with
Es |SV* |get_ANYOF_cp_list_for_ssc \
|NN const RExC_state_t *pRExC_state \
|NN const regnode_charclass_posixl_fold* const node