Piwik 1.3: archive.sh: line 73: 7761 Segmentation fault $CMD

Posted by fabian 

Advanced
fabian [ # ]
April 18, 2011 09:59AM
After Update archive.sh gives many of these errors.

Quote

archive.sh: line 73: 7761 Segmentation fault $CMD

How can I solve this problem?

Fabian
Nocturne [ # ]
April 18, 2011 11:28AM
There is a typo in the file "archive.sh". In line 76 there is a space between "--" and "module" wich has to be removed. After that it worked for me. Sadly automatic archiving per request still fails.
fabian [ # ]
April 18, 2011 11:54AM
I tried your fix in this minute.

Result:
No errors, but NO function too...
Nocturne [ # ]
April 18, 2011 11:59AM
Worked for me. I also have to add that I had to change the database adapter because I do the archiving via web access wich led to a segmentation fault in the PDO adapter. See http://forum.piwik.org/read.php?2,75332 for details

Archiving period = day for idsite = 1...

Archiving period = week for idsite = 1...

Archiving period = month for idsite = 1...

Archiving period = year for idsite = 1...

Archiving for idsite = 1 done!
Reports archiving finished.
---------------------------
Starting Scheduled tasks...

No data available
Finished Scheduled tasks.
April 25, 2011 03:36AM
Quote
Nocturne
There is a typo in the file "archive.sh". In line 76 there is a space between "--" and "module" wich has to be removed. After that it worked for me. Sadly automatic archiving per request still fails.

Thanks! working my way through these speed bumps today. smiling smiley
April 26, 2011 12:53AM
Quote
Dave Lozier
Quote
Nocturne
There is a typo in the file "archive.sh". In line 76 there is a space between "--" and "module" wich has to be removed. After that it worked for me. Sadly automatic archiving per request still fails.

Thanks! working my way through these speed bumps today. smiling smiley

This still didn't seem to help or at least was not consistent. The Piwik_Common::assignCliParametersToRequest() method just parses the command line arguments into the super global $_GET with parse_str() so I simply removed "--" as it's not needed. (or appears to not be)

I'm also running archive.sh as root for the time being while I figure out why www-data doesn't have write permissions where it needs. For now cron based archiving is working for me.
matt [ # ]
April 26, 2011 04:37AM
archive.sh doesn't have a typo or bug in it, as suggested by Nocturne, or at least it is working for hundreds of us, maybe a specific issue with your system?



Cheers,
Matt
Piwik founder

Piwik FAQ - Piwik Help - before posting a new topic
Stay tuned on the Piwik Blog. You may follow me on twitter & on github

fabian [ # ]
April 26, 2011 06:54PM
Quote
matt
archive.sh doesn't have a typo or bug in it...

I can confirm.

After update PHP (5.3.x > 5.3.6-6, Debian 5) all is fine again! Thank you for help. smiling smiley
April 26, 2011 07:59PM
Quote
matt
archive.sh doesn't have a typo or bug in it, as suggested by Nocturne, or at least it is working for hundreds of us, maybe a specific issue with your system?

I agree - I was just noting that the -- dashes appear to not be needed. They'll end up as $_GET['--'] = ''.

I"m still getting some segfaults unfortunately. The server is Ubuntu 10.04 LTS - fully updated. It's a dual dual core opteron box with 10 gigabytes of ram on raid 10 (10k drives).

I have cron set to run archive.sh 3 times an hour - if it segfaults the next run seems to work. One thing I noticed is that I have some archive tables in the database for January of this year but I didn't install Piwik until this past Sunday. I see no January dates in the visit log table so am not sure where these dates are coming from.
matt [ # ]
April 26, 2011 09:40PM
January data in the table is expected, since january will store yearly reports.

Segfault is definitely a bug in PHP, so, maybe you haven't upgraded all to latest version (including libs like PDO etc.) or maybe you found a new bug in a library!



Cheers,
Matt
Piwik founder

Piwik FAQ - Piwik Help - before posting a new topic
Stay tuned on the Piwik Blog. You may follow me on twitter & on github

vipsoft [ # ]
May 05, 2011 06:03PM
If you're using Ubuntu, please apt-get the new packages. There was apparently a regression (or two) in the Ubuntu builds that would cause a seg fault.

- Ubuntu 11.04
- Ubuntu 10.10
- Ubuntu 10.04 LTS
- Ubuntu 9.10
- Ubuntu 8.04 LTS
- Ubuntu 6.06 LTS



Buy me a beer. Show me some love.

Changes in the upcoming release: CHANGES
August 01, 2011 07:13PM
The -- tells php that any tokens that follow should not be taken as option switches, making them available in the argv array. This is a standard behavior for command line tools.
octeny [ # ]
December 13, 2011 04:13PM
Hello,

I did some research on this subject to find a solution. The suggested options in the FAQ Piwik FAQ didn't have an effect on my php - piwik installation. I switched the adapter from PDO_MYSQL to MYSQLI an so on.

I debugged the archiv process and found a "zend_mm_heap corrupted". This error triggered the segmentation fault.

The bug is a PHP Bug is at least noticed but not solved in the current PHP Versions, see https://bugs.php.net/bug.php?id=40479 The thread started in 2007, so it may take some more time until it will be solved ;-)

I decided to make a "hack" in the index.php of my piwik installation to get rid of the segmentation fault. The code will be only executed when the script is executed from the command line. Here is the patch:

ONLY workes on PHP Versions > 5.3.x, see http://de2.php.net/manual/de/function.gc-disable.php!

echo '
#
# SegFault Error - archive.sh  (Debug-Error: "zend_mm_heap corrupted")
# siehe PHP Bug: https://bugs.php.net/bug.php?id=40479
#
if (php_sapi_name() == 'cli') {
        gc_disable();
}
' >> [your piwik installation path]/index.php

System Info:
PHP Version: 5.3.2-1ubuntu4.10
Piwik: 1.6
OS: Ubuntu 10.04.3 LTS



Edited 1 time(s). Last edit at 12/13/2011 04:55PM by octeny.
matt [ # ]
December 14, 2011 03:02AM
Octeny, thank you for the tip! I have updated the FAQ to link to your tip: [piwik.org]



Cheers,
Matt
Piwik founder

Piwik FAQ - Piwik Help - before posting a new topic
Stay tuned on the Piwik Blog. You may follow me on twitter & on github

Valkum [ # ]
December 18, 2011 06:11PM
Your Code do not run as it should.
This would work better.
echo '
#
# SegFault Error - archive.sh  (Debug-Error: "zend_mm_heap corrupted"winking smiley
# siehe PHP Bug: https://bugs.php.net/bug.php?id=40479
#
if (php_sapi_name() == \'cli\') {
        gc_disable();
}
' >> [your piwik installation path]/index.php

Edit: Tomorrow i can give a short response if it works.
It should be integrated in core then with some php check switchs.

Edit2: It works. please push direct to faq and into core.



Edited 3 time(s). Last edit at 12/21/2011 05:36PM by Valkum.
Volox [ # ]
January 04, 2012 05:39AM
I am running on windows and also receiving the "zend_mm_heap corrupted" message every couple of times the archive runs. Any word on when this workaround will make it into the codebase?
March 26, 2012 05:52PM
I confirm the garbage collecting error is still an issue in fresh ubuntu installs.
Disabling GC in the CLI context is not a valid workaround as the archive script calls the API, which in my case is handled by php-fpm.

This brings me two questions:
- Does someone have a better way to disabled GC during the archive process ?
- Does someone know exactly which program is outdated ?

Here is what I have installed (default ubuntu repository):
Piwik 1.7.1
Ubuntu 11.10
Nginx 1.0.5
PHP 5.3.6-13ubuntu3.6 with Suhosin-Patch (cli) (built: Feb 11 2012 03:26:01)
Suhosin Patch 0.9.10
APC 3.1.7
MySQL client: 5.1.58 
GD 2.0
CURL 7.21.6 
matt [ # ]
March 27, 2012 04:52AM
To disable for CLI + when the archive.php is triggered, add this in the top of index.php piwik file:

#
# SegFault Error - archive.sh  (Debug-Error: "zend_mm_heap corrupted"winking smiley
# siehe PHP Bug: [bugs.php.net]
#
if (php_sapi_name() == 'cli'
|| (!empty($_GET['trigger']) && $_GET['trigger'] == 'archivephp')) {
        gc_disable();
}



Cheers,
Matt
Piwik founder

Piwik FAQ - Piwik Help - before posting a new topic
Stay tuned on the Piwik Blog. You may follow me on twitter & on github





Edited 1 time(s). Last edit at 04/10/2012 12:00AM by matt.
March 27, 2012 09:38AM
Thanks matt. It works like a charm.
Harold251 [ # ]
March 27, 2012 11:12AM
I'm also running archive.sh as root for the time being while I figure out why www-data doesn't have write permissions where it needs. For now cron based archiving is working for me.
alexfear [ # ]
April 05, 2012 12:43PM
Your construction \'cli\' somehow breaks my piwik web interface. So i use it without slashes. And... It seems to be working!
Great thanks!

ps: sorry, that's reply to post



Edited 1 time(s). Last edit at 04/05/2012 12:47PM by alexfear.
Lolo irie [ # ]
April 23, 2012 08:34AM
Fix is working for me as well, thanks for posting smiling smiley
August 23, 2012 10:14AM
works for me! .... thx.
January 10, 2014 10:36AM
Hi everybody,
thanks a lot for the tip ! It helped me so much, with everything up to date on debian, the problem occured.

I just changed the tip to be able to use it with php-fpm/fastcgi because php_sapi_name() always returns php-fcgi
-- Still on top of index.php --
if ((isset($_SERVER['_'])) && (preg_match('/archive\.sh/', $_SERVER['_']) == 1)) {
        gc_disable();
}
I think there is several ways to do it, I chose this one...
Hope it will help fresh installs.

EDIT : to identify better the problem I updated system/php to PHP 5.5.7 (the last one on a 2nd Fedora server I have) and the problem disappeared smiling smiley I have 2 servers : the new one on Debian and the old with an old Fedora. Finally, the last Fedora, on this point, is more stable ...



Edited 1 time(s). Last edit at 01/10/2014 10:43AM by florent.lartet.
matt [ # ]
January 12, 2014 11:09PM
@florent.lartet -- I am curious, what version of PHP did you use before upgrading? was it less than 5.3?

because in Piwik 2.0 we removed this code that calls gc_disable() and I hope your bug was on a old version



Cheers,
Matt
Piwik founder

Piwik FAQ - Piwik Help - before posting a new topic
Stay tuned on the Piwik Blog. You may follow me on twitter & on github

January 13, 2014 09:57AM
I had (and still have if I remove the gc_disabel call) the bug on my current version which is
- Piwik 2.0.2 from last week
- Debian 7 up to date
||/ Nom                     Version          Architecture     Description
+++-=======================-================-================-===================================================
ii  mysql-server            5.5.33+dfsg-0+wh all              MySQL database server (metapackage depending on the
un  nginx                   <aucun>                           (aucune description n'est disponible)
ii  php-apc                 3.1.13-1         amd64            APC (Alternative PHP Cache) module for PHP 5
ii  php5                    5.4.4-14+deb7u7  all              server-side, HTML-embedded scripting language (meta
ii  php5-cgi                5.4.4-14+deb7u7  amd64            server-side, HTML-embedded scripting language (CGI
ii  php5-fpm                5.4.4-14+deb7u7  amd64            server-side, HTML-embedded scripting language (FPM-
nginx is version: nginx/1.2.1
It's not working with APC disabled.
The crash happens on our biggest "idsite" 3'000'000 / year
Don't hesitate if you want more information.
matt [ # ]
January 13, 2014 01:21PM
Thanks for the details! I created a ticket at [dev.piwik.org]
Sorry, only registered users may post in this forum.

Click here to login

Free Forum support is provided by the Piwik Community. If you require any urgent or professional help, contact Piwik Professional Services team!