The regular expressions in views_break_phrase() can cause a segmentation fault if there is a large number of arguments passed to the view due to the amount of recursion. This can be solved one of two ways:

  1. Change pcre.backtrack_limit to a more reasonable value. The question here is: what is reasonable? Relying on the end-user to set this appropriately for their installation may be a bit much to ask considering the relative obscurity of this feature.
  2. Refactor the regular expressions to avoid the amount of recursion causing the segmentation fault, namely the ([0-9]+[+ ])+ portion.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BassistJimmyJam’s picture

Status: Active » Needs review
FileSize
774 bytes

Patch attached.

dawehner’s picture

How many arguments did you passed into the view to cause a seg.fault? Is this a number you can estimate?

In general there are multiple issues in both views and drupal issue queue to simplify the regular expression.

BassistJimmyJam’s picture

I had over 7000 arguments being passed to the view. I'm not sure what the minimum number of arguments would be that would cause this issue. I searched the views issue queue before posting but was unable to find any issues addressing these specific regular expressions.

dawehner’s picture

dawehner’s picture

In general this sounds wrong: 7k arguments to a view, ... can you please have a look at the other issue whether that new regex makes it easier?

BarisW’s picture

I was having a similar issue. On Drupal Commons, visiting the /activity page as a logged-in user, I was getting the segmentation fault as well. Described here: #2150673: Activity overview is broken for normal users

BarisW’s picture

Issue summary: View changes

Can this be committed?

clemens.tolboom’s picture

Hmmm ... the Drupal 8 views fix in #1792836: Merge HandlerBase::breakPhrase() and HandlerBase::breakPhraseString() and clean up does not follow the patch from #1 regarding recursion depths.

- if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $str)) {
+ // Determine if the string has 'or' operators (plus signs) or 'and'
+ // operators (commas) and split the string accordingly.
+ if (preg_match('/^([\w0-9-_]+[+ ]+)+[\w0-9-_]+$/u', $str)) {

@BassistJimmyJam where did those 7K argument come from?

Side info : nice way to test @ http://www.phpliveregex.com/

BassistJimmyJam’s picture

It's been awhile since I ran into this, but I believe they came form a default argument plugin. Those arguments were also passed to the link for the attached CSV export.

Chris Matthews’s picture

The 6 year old patch in #1 to handlers.inc applied cleanly to the latest views 7.x-3.x-dev and if still relevant needs to be reviewed.