Segmentation fault

[size=x-large]Piwik segmentation fault FAQ with solution list now published. Check it out: Troubleshooting - Analytics Platform - Matomo

Joe: what version of Piwik are you running? what OS is the piwik server running on? can you check the server logs? can you run archive.sh from the command line (instead of cron) and see if there is more information on the error?

Hi,

I am running 0.2.33.
My server:
openSUSE 10.3, php 5.2.5 and mySQL 5.0.45.
The same error occurs when I try to start archiving from the command line.

Greetings,
Joe

[quote=joey001 @ Apr 11 2009, 02:43 PM]Hi,
The same error occurs when I try to start archiving from the command line.

Greetings,
Joe[/quote]

Error in my logfile:
php5[31862]: segfault at 700000040 ip 000000000054dcf7 sp 00007ffff23a4660 error 4 in php5[400000+266000]

Check your php.ini configuration. The command line php may have a lower memory_limit. (e.g., /etc/php5/cli/php.ini)

CLI php memory limit set to 256M, problem remains…
:frowning:

Greetings,
Joe

update your php version, this is most likely due to a bug in php

I have the same problem when running archive.sh. Running an strace shows that it happens after reading data from the mysql query. I can reproduce this easily.

CentOS 5.2, php 5.2.9
also affects: CentOS 5.2, php 5.1.6 (stock)

[root@stats1 ~]# /usr/bin/php -v
PHP 5.2.9 (cli) (built: Mar 17 2009 12:06:16)
Copyright © 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright © 1998-2009 Zend Technologies
[root@stats1 ~]# uname -a
Linux stats1 2.6.24-23-xen #1 SMP Mon Jan 26 03:09:12 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux
[root@stats1 ~]# grep memory_limit /etc/php.ini
memory_limit = 2048M ; Maximum amount of memory…
[root@stats1 ~]# /usr/bin/php /var/www/html/misc/cron/…/…/index.php – 'module=API&method=VisitsSummary.getVisits&idSite=all&period=day&date=last52&format=xml&token_auth=xxxxxxxxxxxxxxxxxxxxxxxxxxxx’
Segmentation fault

Strace excerpt. Note that fd number 4 is the connection to the MySQL server.

brk(0x1f2d000) = 0x1f2d000
brk(0x1f6d000) = 0x1f6d000
brk(0x1fad000) = 0x1fad000
poll([{fd=4, events=POLLIN|POLLPRI}], 1, 0) = 0 (Timeout)
write(4, “\235\1\0\0\3SELECT \tname,\n\t\t\t\t\t\t\ttype,\n”…, 417) = 417
read(4, “\1\0\0\1\5C\0\0\2\3def\5stats\20stats_log_ac”…, 16384) = 16384
read(4, “us died and rose, but not on Fri”…, 16384) = 16384
read(4, “nist loses medical license\0011\0011\0011”…, 16384) = 16384
read(4, “\0\0\225$Documents reveal 'shadow gov”…, 16384) = 16384
read(4, “\00220\00220\002170\0\0\310’NBC trashes pro-li”…, 16384) = 16384
read(4, “a expanding ban on 'assault weap”…, 16384) = 16384
read(4, “tes satanic, sex calendar\0011\0011\0011\1”…, 16384) = 16384
read(4, “th records on sale block\0011\0011\0011\0011”…, 16384) = 16384
read(4, “P senator\0011\0011\0011\0010#\0\0\214\32http://www”…, 16384) = 16384
read(4, “her’s ode to his daughter\0011\0011\0011\1”…, 16384) = 16384
read(4, “\0\0\3711Moral poverty cost blacks&lt”…, 16384) = 14556
brk(0x1fed000) = 0x1fed000
brk(0x202d000) = 0x202d000
brk(0x206d000) = 0x206d000
brk(0x20ad000) = 0x20ad000
brk(0x20ed000) = 0x20ed000
brk(0x212d000) = 0x212d000
brk(0x216d000) = 0x216d000
poll([{fd=4, events=POLLIN|POLLPRI}], 1, 0) = 0 (Timeout)
write(4, “\225\1\0\0\3SELECT \tname,\n\t\t\t\t\t\t\ttype,\n”…, 409) = 409
read(4, “\1\0\0\1\3=\0\0\2\3def\5stats\nlog_action\20s”…, 16384) = 16384
read(4, “3%\0\0E\36Jesse Dirkhising’s deliver”…, 16384) = 16384
read(4, “\0\0z3Obama’s training program des”…, 16384) = 16384
read(4, “e\0011\00154\0\0\276-Americans rally behind”…, 16384) = 16384
read(4, “o go\0011\0032610\0\0\354)http://www.jaynad”…, 16384) = 16384
read(4, “)\36In whose numbers do you trust?”…, 16384) = 16384
read(4, “rack Obama\0011\003135,\0\0^&Barack Obam”…, 16384) = 15021
brk(0x21ad000) = 0x21ad000
brk(0x21ed000) = 0x21ed000
brk(0x222d000) = 0x222d000
brk(0x226d000) = 0x226d000
brk(0x22ad000) = 0x22ad000
— SIGSEGV (Segmentation fault) @ 0 (0) —
+++ killed by SIGSEGV +++

Next, I noticed that there were some unusual characters in the piwik_log_action.name field because I was using piwik_action_name = document.title in the javascript that calls the piwik.php script (importer). So my guess here is that some text is unescaped, and causing the trouble.

I replaced all the information in the piwik_log_action.name column, and re-ran the archive.sh command, and bingo. No more segfault.

Can you rollback your database and try a manual conversion?

Example (i.e., you have to adapt this to your environment): http://weblogger.ch/blog/2006/09/07/passage-a-utf-8/

I installed Piwik from the scratch, now it works. Lets wait a few days and see what happens, after Piwik has collected some data.

Greetings,
Joe

Hi,
I have the same problem as described above.
My Environment:

Piwik 0.2.34, same with 0.2.33
Linux 2.6.24-etchnhalf.1-amd64 #1 SMP Fri Dec 26 03:26:12 UTC 2008 x86_64 GNU/Linux
PHP 5.2.0-8+etch13 (cli) (built: Sep 30 2008 18:37:38) 
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies with the ionCube PHP Loader v3.1.28, Copyright (c) 2002-2007, by ionCube Ltd.

Problem:

  1. The Cron Job and running the PHP command on the command line abort with a segmentation fault.
  2. Surfing the statistics of one of my 5 sites isn’t possible since the upgrade to Version 0.2.33.

What wonders me is that I can view the statistics of that site (IDSITE: 2) when that time is before I upgraded to version 0.2.33. If I change the date in Piwik to a day after I upgraded Piwik from version 0.2.29 to 0.2.33 the statistics don’t display.

If I modify the archive script to use a number instead of “all” for the parameter “idsite” it runs through if I leave away the idsite 2.
There must be a problem with the statistics of the site with the ID 2, which occured after I upgraded to version 0.2.33.

Should I file a ticket for that? Regardless of it’s a PHP bug or not, Piwik doesn’t seem to handle data correctly when inserting it into the table.

My statistics are quite huge (> 1.9GB), so I can’t post a dump to analyze the problem.

ciao, Sören

[quote=Adrian @ Apr 15 2009, 08:31 PM]…
Next, I noticed that there were some unusual characters in the piwik_log_action.name field because I was using piwik_action_name = document.title in the javascript that calls the piwik.php script (importer). So my guess here is that some text is unescaped, and causing the trouble.

I replaced all the information in the piwik_log_action.name column, and re-ran the archive.sh command, and bingo. No more segfault.[/quote]

Ok, that solved the problem for me too. I replaced all the values in the “name” column with the same string, now it works. I have more than 560.000 entries in that column, so it took a while. I’m not using the document.title as piwik_log_action btw.
Regarding “convert it to UTF-8”: The piwik_log_action.name column has utf_general_ci encoding, so I guess the data in it is already UTF8-encoded (there’s no need to convert it to UTF-8).

thanks,
Sören

[quote=Sören @ Apr 22 2009, 12:20 PM]I replaced all the values in the “name” column with the same string, now it works.

thanks,
Sören[/quote]

How did you replace the values in the “name” column with the same string? Export them from the DB and re-import them?

Greetings,
Joe

Piwik now ran 12 days without any error, but since last night once again:
segmentation fault…

style_emoticons/<#EMO_DIR#>/angry.gif

[quote=joey001 @ Apr 30 2009, 09:39 AM]Piwik now ran 12 days without any error, but since last night once again:
segmentation fault…

style_emoticons/<#EMO_DIR#>/angry.gif[/quote]

I did a repair on all tables of the Piwik-DB, now it works again!
style_emoticons/<#EMO_DIR#>/biggrin.gif

The problem was:
piwik_log_link_visit_action repair warning Number of rows changed from 158049 to 158046

Greetings,
Joe

I’m getting a similar segmentation fault when running archive.sh. For me, it was happening on this line in core/DataTable.php in the getSerialized function.

foreach($this->rows as $row)

I changed it to the, I hope, semantically equivalent

while (list(, $row) = each($this->rows))

And (touch wood) it seems to be running now…

Other things didn’t help - e.g. increasing memory_limit, using MALLOC_CHECK_=1, rebuilding tables, upgrading from etch to lenny to get 5.2.6.dfsg.1-1+lenny3.

I mean, of course,

reset($this->rows); while (list(, $row) = each($this->rows))

Or else it won’t loop over anything. It still seems to help though…

[quote=frabcus @ May 28 2009, 05:32 PM]I mean, of course,

reset($this->rows); while (list(, $row) = each($this->rows))

Or else it won’t loop over anything. It still seems to help though…[/quote]

it sounds to me like a bug in your php release, what php version are you using? could you try and upgrade and report how it is working with the foreach?

Yes, it’s a PHP bug - or perhaps a bug in the MySQL PHP module. I’m using PHP 5.2.6-1+lenny3 on Debian Lenny.

It was happening originally with PHP 5.2.0-8+etch15 on Debian Etch, and I upgraded the server to Lenny to see if the bug was fixed in the newer version of PHP, and it wasn’t.

I can’t easily upgrade to a newer PHP, as we only run stable versions of Debian on our servers.

I haven’t managed to isolate the bug to a piece of code small enough to submit as a bug for PHP, and can’t find anyone else who has. It is clearly affecting a few Piwik user’s though, and that isolation sounds like the next phase.

If there are issues with PHP versions, I suggest updating the requirements to state a newer version of PHP. I’m running centos with php 5.1.6 and we are seeing lots of errors and segfaults.