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

Comments

Status: Needs review » Needs work

The last submitted patch, drupal_parse_info_format_preg_match_seg_fault.patch, failed testing.

killerpoke’s picture

killerpoke’s picture

Status: Needs work » Needs review
David_Rothstein’s picture

Looks 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.

David_Rothstein’s picture

For 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.

webcultist’s picture

#2 works very well for me. Had this issue with the json3 node.js module, mentioned in #2329453.

gmclelland’s picture

I think the patch in #2 no longer applies.

darol100’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
andypost’s picture

  1. +++ b/includes/common.inc
    @@ -7331,7 +7331,39 @@ function drupal_parse_info_format($data) {
    +  $lines = explode('
    +', $data);
    

    suppose "\n" but some contrib could have "\n\r"

  2. +++ b/includes/common.inc
    @@ -7331,7 +7331,39 @@ function drupal_parse_info_format($data) {
    +        $multi_line .= '
    +' . $lines[$c + 1];
    ...
    +        $multi_line .= '
    +' . $lines[$c + 1];
    

    please use "\n"

chellman’s picture

StatusFileSize
new1.87 KB

I was getting bitten by this bug. Here's a re-rolled patch.

chellman’s picture

Status: Needs work » Needs review
andypost’s picture

Status: Needs review » Needs work

For #9

chellman’s picture

StatusFileSize
new1.95 KB

Re-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.

chellman’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 13: 2349457-segfault-parse-info-13.patch, failed testing.

chellman’s picture

Status: Needs work » Needs review
StatusFileSize
new1.87 KB

Fixed the patch.

opdavies’s picture

Status: Needs review » Reviewed & tested by the community

I'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.

andrew answer’s picture

Issue tags: -Needs reroll
poker10’s picture

Issue tags: -preg_match +Needs tests

The test @David_Rothstein mentioned is still missing here.

jmizarela’s picture

Status: Reviewed & tested by the community » Needs work

As test is missing, moving to Needs work

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.