0

Trying to help a Magento store owner (Pro 1.11.0.0) track down php segfaults from their store. We are seeing a few segfaults per minute. All the backtraces are:

#0  match (eptr=0x9ab0213 "') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", 
    ecode=0x154bd7b "\035\\\035'q", 
    mstart=0x9ab020a "'category') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", offset_top=4, 
    md=0x7fff88cb88a0, eptrb=0x0, rdepth=18) at /home/admin/php-5.4.32/ext/pcre/pcrelib/pcre_exec.c:500
#1  0x000000000047972a in match (eptr=0x9ab0213 "') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", 
    ecode=0x154bd76 "\177", 
    mstart=0x9ab020a "'category') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", 
    offset_top=<value optimized out>, md=0x7fff88cb88a0, eptrb=0x2, rdepth=17)
    at /home/admin/php-5.4.32/ext/pcre/pcrelib/pcre_exec.c:973
#2  0x000000000048523c in match (eptr=0x9ab0213 "') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", 
    ecode=0x154bd8b "s", 
    mstart=0x9ab020a "'category') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", offset_top=4, 
    md=0x7fff88cb88a0, eptrb=0x0, rdepth=16) at /home/admin/php-5.4.32/ext/pcre/pcrelib/pcre_exec.c:2039
#3  0x000000000047972a in match (eptr=0x9ab0212 "y') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", 
    ecode=0x154bd86 "q", 
    mstart=0x9ab020a "'category') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", 
    offset_top=<value optimized out>, md=0x7fff88cb88a0, eptrb=0x2, rdepth=15)
    at /home/admin/php-5.4.32/ext/pcre/pcrelib/pcre_exec.c:973
#4  0x000000000048523c in match (eptr=0x9ab0212 "y') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", 
    ecode=0x154bd8b "s", 
    mstart=0x9ab020a "'category') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", offset_top=4, 
    md=0x7fff88cb88a0, eptrb=0x0, rdepth=14) at /home/admin/php-5.4.32/ext/pcre/pcrelib/pcre_exec.c:2039
#5  0x000000000047972a in match (
    eptr=0x9ab0211 "ry') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", ecode=0x154bd86 "q", 
    mstart=0x9ab020a "'category') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", 
    offset_top=<value optimized out>, md=0x7fff88cb88a0, eptrb=0x2, rdepth=13)
    at /home/admin/php-5.4.32/ext/pcre/pcrelib/pcre_exec.c:973
#6  0x000000000048523c in match (
    eptr=0x9ab0211 "ry') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", ecode=0x154bd8b "s", 
    mstart=0x9ab020a "'category') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", offset_top=4, 
    md=0x7fff88cb88a0, eptrb=0x0, rdepth=12) at /home/admin/php-5.4.32/ext/pcre/pcrelib/pcre_exec.c:2039
#7  0x000000000047972a in match (
    eptr=0x9ab0210 "ory') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", ecode=0x154bd86 "q", 
    mstart=0x9ab020a "'category') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", 
    offset_top=<value optimized out>, md=0x7fff88cb88a0, eptrb=0x2, rdepth=11)
    at /home/admin/php-5.4.32/ext/pcre/pcrelib/pcre_exec.c:973
#8  0x000000000048523c in match (
    eptr=0x9ab0210 "ory') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", ecode=0x154bd8b "s", 
    mstart=0x9ab020a "'category') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", offset_top=4, 
    md=0x7fff88cb88a0, eptrb=0x0, rdepth=10) at /home/admin/php-5.4.32/ext/pcre/pcrelib/pcre_exec.c:2039
#9  0x000000000047972a in match (
    eptr=0x9ab020f "gory') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", ecode=0x154bd86 "q", 
    mstart=0x9ab020a "'category') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", 
    offset_top=<value optimized out>, md=0x7fff88cb88a0, eptrb=0x2, rdepth=9)
    at /home/admin/php-5.4.32/ext/pcre/pcrelib/pcre_exec.c:973
#10 0x000000000048523c in match (
    eptr=0x9ab020f "gory') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", ecode=0x154bd8b "s", 
    mstart=0x9ab020a "'category') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", offset_top=4, 
    md=0x7fff88cb88a0, eptrb=0x0, rdepth=8) at /home/admin/php-5.4.32/ext/pcre/pcrelib/pcre_exec.c:2039
#11 0x000000000047972a in match (
    eptr=0x9ab020e "egory') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", ecode=0x154bd86 "q", 
    mstart=0x9ab020a "'category') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", 
    offset_top=<value optimized out>, md=0x7fff88cb88a0, eptrb=0x2, rdepth=7)
    at /home/admin/php-5.4.32/ext/pcre/pcrelib/pcre_exec.c:973
#12 0x000000000048523c in match (
    eptr=0x9ab020e "egory') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", ecode=0x154bd8b "s", 
    mstart=0x9ab020a "'category') AND (t_def.store_id IN (0, '2')) ORDER BY `t_def`.`store_id` DESC LIMIT 1", offset_top=4, 
    md=0x7fff88cb88a0, eptrb=0x0, rdepth=6) at /home/admin/php-5.4.32/ext/pcre/pcrelib/pcre_exec.c:2039
#13 0x000000000047972a in match (

The SQL query shown above appears to be from the file: code/core/Mage/GoogleOptimizer/Model/Resource/Code.php

public function loadbyEntityType($object, $storeId) { $adapter = $this->_getReadAdapter();

$codeIdExpr             = $adapter->getCheckSql(
    't_store.code_id IS NOT NULL',
    't_store.code_id',
    't_def.code_id');
$storeIdExpr            = $adapter->getCheckSql(
    't_store.store_id IS NOT NULL',
    't_store.store_id',
    't_def.store_id');
$controlScriptExpr      = $adapter->getCheckSql(
    't_store.control_script IS NOT NULL',
    't_store.control_script',
    't_def.control_script');
$trackingScriptExpr     = $adapter->getCheckSql(
    't_store.tracking_script IS NOT NULL',
    't_store.tracking_script',
    't_def.tracking_script');
$conversionScriptExpr   = $adapter->getCheckSql(
    't_store.conversion_script IS NOT NULL',
    't_store.conversion_script',
    't_def.conversion_script');
$conversionPageExpr     = $adapter->getCheckSql(
    't_store.conversion_page IS NOT NULL',
    't_store.conversion_page',
    't_def.conversion_page');
$additionalDataExpr     = $adapter->getCheckSql(
    't_store.additional_data IS NOT NULL',
    't_store.additional_data',
    't_def.additional_data');

$select = $adapter->select()
    ->from(
        array('t_def' => $this->getMainTable()),
        array('entity_id', 'entity_type'))
    ->joinLeft(
        array('t_store' => $this->getMainTable()),
        't_store.entity_id = t_def.entity_id AND t_store.entity_type = t_def.entity_type AND '
            . $adapter->quoteInto('t_store.store_id = ?', $storeId),
        array(
            'code_id'           => $codeIdExpr,
            'store_id'          => $storeIdExpr,
            'control_script'    => $controlScriptExpr,
            'tracking_script'   => $trackingScriptExpr,
            'conversion_script' => $conversionScriptExpr,
            'conversion_page'   => $conversionPageExpr,
            'additional_data'   => $additionalDataExpr))
    ->where('t_def.entity_id=?', $object->getEntity()->getId())
    ->where('t_def.entity_type=?', $object->getEntityType())
    ->where('t_def.store_id IN (0, ?)', $storeId)
    ->order('t_def.store_id DESC')
    ->limit(1);
$data = $adapter->fetchRow($select);
if ($data) {
    $object->setData($data);
}
$this->_afterLoad($object);
return $this;

}

Any thoughts / pointers as to what may be causing this issue? They do have the Google Optimizer enabled.

  • Looks like ecode is not properly null terminated and going out of bounds. This isn't something php code can do on its own. Do you know how the PCRE extension for php was installed? – Melvyn Aug 29 '14 at 17:48
  • Standard php-fpm config for php 5.4.32: ./configure --with-mysql=/usr/local/mysql --with-config-file-path=/home/xyz/php-5.4.32 --with-gd --enable-fpm --with-zlib=/usr --with-png-dir=/usr --enable-ftp --with-jpeg-dir=/usr --with-curl=/usr --with-openssl --enable-sockets --enable-track-vars --with-xmlrpc --with-mcrypt=/usr/local --with-libxml --with-freetype-dir=/usr --enable-pdo --with-pdo-sqlite --with-sqlite --with-pdo-mysql=/usr/local/mysql --enable-mbstring=all --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-zip --with-xsl – Rob Mangiafico Aug 29 '14 at 18:02
  • Adding a link to your PHP bug for reference: bugs.php.net/bug.php?id=67926&edit=1 -- IMHO this is something wrong with your PHP install on this box. – JasonS Aug 30 '14 at 2:57
  • I recompiled PHP, updated ioncube to the latest version, etc... still same segfault errors. I don't see any issues from a server standpoint. – Rob Mangiafico Aug 30 '14 at 12:53
1

Noticed a similar problem lately after a server update. In the end it was an apc-issue. Disabling apc solved the problem...

  • mostly caused because people dont know, apc as opcache is only supported till php 5.3, there is no stable & full working version for php >=5.4 – Flyingmana Sep 20 '14 at 23:51
  • This specific store is running Zend Opcache instead of APC. – Rob Mangiafico Sep 21 '14 at 1:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.