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

I can confirm.

After update PHP (5.3.x > 5.3.6-6, Debian 5) all is fine again! Thank you for help. :slight_smile:

[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?[/quote]

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.

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!

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

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.

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 zend_mm_heap Bug The thread started in 2007, so it may take some more time until it will be solved :wink:

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 gc_disable !


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

Octeny, thank you for the tip! I have updated the FAQ to link to your tip: Troubleshooting - Analytics Platform - Matomo

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.

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?

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 

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: https://bugs.php.net/bug.php?id=40479
#
if (php_sapi_name() == 'cli'
|| (!empty($_GET['trigger']) && $_GET['trigger'] == 'archivephp')) {
        gc_disable();
}

Thanks matt. It works like a charm.

http://www.infoocean.info/avatar2.jpgI’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.

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

Fix is working for me as well, thanks for posting :slight_smile:

works for me! … thx.

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 :slight_smile: 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 …

@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

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.

Thanks for the details! I created a ticket at Segmentation fault in archiving on latest stable php · Issue #4507 · matomo-org/matomo · GitHub