When module .info files are too large, preg_match_all will fail on many Apache systems with no error message but a Segmentation foult log to the apache error log:
child pid XXX exit signal Segmentation fault (11)
I think, this is not a drupal bug, or a php bug, since the PHP PCRE adapter just crashes, when the data passed to greg_match_all is too big.
Normally the module.info files won't get really large, but when you include third-party libraries, you may also include a .info file, that is really big. Even if this .info file is not a drupal module info file, drupal_parse_info_format() will parse the file.
To avoid this, I created a little patch, to change the single preg_match_all call into a loop of single preg_match calls for each line.
Important: I tested this patch just with some modules, it works fine. I don't know if there is a performance issue or that some modules info files won't get parsed right, but I think this patch should not do any harm to the drupal core, since the only thing it does, is replacing preg_match_all with many single preg_match requests
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 2349457-segfault-parse-info-16.patch | 1.87 KB | chellman |
| #13 | 2349457-segfault-parse-info-13.patch | 1.95 KB | chellman |
| #10 | 2349457-segfault-parse-info-10.patch | 1.87 KB | chellman |
| #2 | drupal_parse_info_format_preg_match_seg_fault-1.patch | 1.86 KB | killerpoke |
Comments
Comment #2
killerpoke commentedComment #3
killerpoke commentedComment #4
David_Rothstein commentedLooks like a potentially good approach. Note that #2329453-19: Ignore front end vendor folders to improve directory search performance is an example of an .info file that breaks without this, but which drupal_parse_info_format() is able to parse with this patch applied.
A test (perhaps somehow based on that) could be useful here.
Comment #5
David_Rothstein commentedFor clarity (since I wrote this backwards the first time around and then went back and edited my above comment) #2329453-19: Ignore front end vendor folders to improve directory search performance is an example of an .info file that currently triggers a segmentation fault but which the patch in this issue fixes.
Comment #6
webcultist commented#2 works very well for me. Had this issue with the json3 node.js module, mentioned in #2329453.
Comment #7
gmclelland commentedI think the patch in #2 no longer applies.
Comment #8
darol100 commentedComment #9
andypostsuppose "\n" but some contrib could have "\n\r"
please use "\n"
Comment #10
chellman commentedI was getting bitten by this bug. Here's a re-rolled patch.
Comment #11
chellman commentedComment #12
andypostFor #9
Comment #13
chellman commentedRe-cut the patch with the suggestions from #9. Coding standards specifically say \n for line endings so I'm not dealing with \n\r or anything else.
Comment #14
chellman commentedComment #16
chellman commentedFixed the patch.
Comment #17
opdaviesI've had the same issue where I've suddenly started getting segmentation faults on a 7.56 site on pages such as /admin and also when performing Drush to perform tasks such as clearing the cache.
Applying the patch in #16 allows me to access those pages again.
Comment #18
andrew answer commentedComment #19
poker10 commentedThe test @David_Rothstein mentioned is still missing here.
Comment #20
jmizarela commentedAs test is missing, moving to Needs work