Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugging out with deeply nested action urls #824

Closed
robocoder opened this issue Jun 24, 2009 · 5 comments
Closed

Bugging out with deeply nested action urls #824

robocoder opened this issue Jun 24, 2009 · 5 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical. worksforme The issue cannot be reproduced and things work as intended.
Milestone

Comments

@robocoder
Copy link
Contributor

Patch from crowbot:

I've done a bit more work on trying to isolate this bug, using the same data set as frabcus. I've had some success in tracking it down further, and got a fix but not a definitive answer as to what the issue is.

Basically, the Actions plugin in piwik makes nested arrays to represent different 'actions' (url segments) in the logs of site visits. These then get made into DataTables, with various different sorting and limiting filters being applied to them.

The situation that I think causes the segfault is that there's a url with more than 10 slash-separated path segments in it, on a day when there are also more than 100 rows to record and archive. The url causes 10-deep array to be built (which is normally fine) but then the fact that there are more than 100 records causes filters to be applied to sort the records in the resulting data table, remove some, and add a summary row. This process somehow corrupts the data table such that any subsequent attempt to access rows in it causes a segfault (or on OSX, a bus error). It's fairly icky as the filter classes are generated on the fly and I think the problem may be something to do with several on-the-fly created classes holding a reference to this deeply nested array with objects in it. For now, the problem seems solved by unsetting a reference to it in the final filter after use.

--- core/DataTable/Filter/AddSummaryRow.php     (revision 1152)
+++ core/DataTable/Filter/AddSummaryRow.php     (working copy)
@@ -68,5 +68,6 @@
               $newRow->setColumns(array('label' =>
$this->labelSummaryRow) + $newRow->getColumns());
               $this->table->filter('Limit', array(0,
$this->startRowToSummarize));
               $this->table->addSummaryRow($newRow);
+               unset($rows);
       }
 }

http://forum.piwik.org/index.php?showtopic=830&view=findpost&p=2980

@mattab
Copy link
Member

mattab commented Jun 25, 2009

did you test this patch in prod?

did unit tests passed?

@robocoder
Copy link
Contributor Author

Unit tests pass and it doesn't seem to have any negative side effects on my system, but I don't have deeply nested URLs. crowbot proposed and another user confirmed the fix on the forum.

I'll try to set-up some dummy data to test before commiting.

That said, I'm perplexed how this is a fix as it unsets a local variable. How messed up is reference counting in PHP?!

@robocoder
Copy link
Contributor Author

Ok, an unofficial explanation: http://ca.php.net/manual/en/function.unset.php#56332

@robocoder
Copy link
Contributor Author

This is still being investigated as I haven't been able to reproduce the segfault or memory leak. (In fact, when I add the unset(), memory_get_usage() appears to be higher than without.) I also tried increasing the max recursion level to the maximum (15) in test_serializeWithDeepNesting().

@robocoder
Copy link
Contributor Author

(In [1308]) refs #824 - workaround reported seg fault in some php builds/versions with deeply nested action URLs

@robocoder robocoder added this to the Piwik 0.4.2 milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical. worksforme The issue cannot be reproduced and things work as intended.
Projects
None yet
Development

No branches or pull requests

2 participants