php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9840 seg fault on apache
Submitted: 2001-03-19 11:42 UTC Modified: 2001-03-22 08:06 UTC
From: tdavis at birddg dot com Assigned:
Status: Not a bug Package: Apache related
PHP Version: 4.0.4-cvs.03-21-01 9pm CST OS: Linux Slackware 7.1
Private report: No CVE-ID: None
 [2001-03-19 11:42 UTC] tdavis at birddg dot com
here is my configure line:
./configure --with-zlib --with-mm --with-mysql=/usr/local/mysql --with-mcal=../libmcal --with-imap=../../imap --with-gettext --enable-ftp --with-db3=/usr/local/BerkeleyDB.3.2 --with-apache=/usr/local/apache --with-mcrypt

I am using IMP from the HORDE project if you are familiar with it. 

The script that it appears to be failing on is as follows, it is rather long sorry:

<?php
function isPreferred($server, $key = null)
{
    global $HTTP_SERVER_VARS;
    static $urlServer;
    
    if (!isset($urlServer)) $urlServer = Horde::getFormData('server');
    if (!empty($urlServer)) {
        return $key == $urlServer;
    }
    
    if (is_array($server['preferred'])) {
        foreach ($server['preferred'] as $preferred) {
            if ($preferred == $HTTP_SERVER_VARS['SERVER_NAME'] ||
                $preferred == $HTTP_SERVER_VARS['HTTP_HOST']) {
                return true;
            }
        }
    } elseif ($server['preferred'] == $HTTP_SERVER_VARS['SERVER_NAME'] ||
              $server['preferred'] == $HTTP_SERVER_VARS['HTTP_HOST']) {
        return true;
    }

    return false;
}

define('IMP_BASE', dirname(__FILE__));
require_once IMP_BASE . '/lib/base.php';
if ($conf['connections']['track']) {
    include_once IMP_BASE . '/../lib/Connection.php';
}

/* Additional configuration (dependent on the above code libraries) */
require IMP_BASE . '/config/servers.php';

if ($conf['log']['enabled']) {
    include_once 'Log.php';
    $log = &Log::singleton($conf['log']['type'], $conf['log']['name'],
                           $conf['log']['ident'], $conf['log']['conf']);
}

/* Map the various values for $reason to more descriptive status messages. */
$reasons = array('login'   => '',
                 'timeout' => _("Either you have logged in incorrectly or your login has expired. Please login again."),
                 'logout'  => sprintf(_("You have been logged out of %s. Thank you for using the system. If you wish to log in again, please use the form below."), $conf['sitename']),
                 'failed'  => _("Login failed for some reason. Most likely your username or password was entered incorrectly."));

/* Default to 'login' if no $reason is set. */
$reason = Horde::getFormData('reason', 'login');
$actionID = Horde::getFormData('actionID', NO_ACTION);

/* Initialize the session routines. */
session_name($conf['session_name']);
@session_start();

if (isset($HTTP_SESSION_VARS['imp']) && is_array($HTTP_SESSION_VARS['imp'])) {
    if ($reason == 'logout') {
        $imp = &$HTTP_SESSION_VARS['imp'];
        if (isset($imp['user'])) {
            $prefs = Prefs::factory($conf['prefs']['driver'],
                $registry->getApp(), $imp['user'],
                Secret::read(Secret::getKey('imp'), $imp['pass']),
                $conf['prefs']['params']);
            $prefs->store();
        }
        $HTTP_SESSION_VARS['imp'] = null;
        session_unregister('imp');
    } elseif ($reason == 'failed') {
        $HTTP_SESSION_VARS['imp'] = null;
        session_unregister('imp');
    } else {
        /* If there is an existing session, redirect the user to the mailbox. */
        if ($actionID == IMP_LOGIN) {
            header('Location: ' . Horde::applicationUrl('mailbox.php?actionID=' . IMP_LOGIN, true));
            exit;
        } elseif (($actionID == LOGIN_COMPOSE) || (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'compose'))) {
            header('Location: ' . Horde::applicationUrl('mailbox.php?actionID=' . LOGIN_COMPOSE, true));
            exit;
        } else {
            header('Location: ' . Horde::applicationUrl('mailbox.php', true));
            exit;
        }
    }
}

/* Log the reason if logging is enabled. */
if ($conf['log']['enabled']) {
    $log->log($HTTP_SERVER_VARS['REMOTE_ADDR'] . ' ' . $reason, LOG_INFO);
}

/* Redirect the user on logout if redirection is enabled. */
if (($reason == 'logout') && $conf['user']['redirect_on_logout']) {
    header('Location: ' . $conf['user']['redirect_on_logout']);
    exit;
}

/* Redirect the user if an alternate login page has been specified. */
if ((in_array($reason, array('login', 'failed', 'timeout'))) && $conf['user']['alternate_login']) {
    header('Location: ' . $conf['user']['alternate_login']);
    exit;
}

/* Initialize the password key. */
Secret::setKey('imp');

/* Set the actionID of the login form */
if ((isset($HTTP_GET_VARS['action']) && $HTTP_GET_VARS['action'] == 'compose') ||
    ($actionID == LOGIN_COMPOSE)) {
    $actionID = LOGIN_COMPOSE;
} else {
    $actionID = IMP_LOGIN;
}

/* Get the default preferences values. */
$prefs = Prefs::factory('none', $registry->getApp());
$prefs->setDefaults(IMP_BASE . '/config/prefs.php');

/* Grab some default values from the first entry in config/servers.php. */
reset($servers);
$server_key = key($servers);
$server_value = $servers[$server_key]['server'];
$protocol_value = $servers[$server_key]['protocol'];
$port_value = $servers[$server_key]['port'];
$folders_value = $servers[$server_key]['folders'];
$namespace_value = $servers[$server_key]['namespace'];
$maildomain_value = $servers[$server_key]['maildomain'];

/*
 * If the server list is used but should be hidden (for virtual hosting),
 * make sure we output a server name to use.
 */
if ($conf['server']['server_list'] && $conf['server']['server_list_hidden']) {
    /*
     * Iterate through the servers in an attempt to locate a "preferred"
     * server for this web server.  If none if found, we default to the
     * first entry in the hash (indicated by the $server_key value set
     * above).
     */
    foreach ($servers as $key => $curServer) {
        if (isPreferred($curServer, $key)) {
            $server_key = $key;
            break;
        }
    }
}

/* Build the <select> widget for the servers list. */
if ($conf['server']['server_list'] && !$conf['server']['server_list_hidden']) {
    $servers_list = '';

    foreach ($servers as $key => $curServer) {
        $sel = (isPreferred($curServer, $key)) ? ' selected="selected"' : '';
        $servers_list .= "<option value=\"$key\"$sel>";
        $servers_list .= $curServer['name'] . "</option>\n";
    }
}

/* Build the <select> widget containing the available languages. */
if (!$prefs->isLocked('language')) {
    $langs = '<select name="new_lang" onchange="selectLang()">';
    foreach ($nls['languages'] as $key => $val) {
        $sel = ($key == $language) ? ' selected="selected"' : '';
        $langs .= "<option value=\"$key\"$sel>$val</option>\n";
    }
    $langs .= '</select>';
}

$title = _("Welcome");
$js_onLoad = 'setFocus()';
include $conf['paths']['templates'] . '/doctype.inc';
include $conf['paths']['templates'] . '/common-header.inc';
include $conf['paths']['templates'] . '/login/login.inc';
if (@is_readable(IMP_BASE . '/config/MOTD.html')) {
    include IMP_BASE . '/config/MOTD.html';
}
include $conf['paths']['templates'] . '/common-footer.inc';

?>

Thank you!
Terry

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-19 14:02 UTC] sniper@php.net
First get the latest CVS snapshot from http://snaps.php.net/
and then configure it using the same configure line you
have included here but add --enable-debug into it.

And then generate a gdb backtrace of the crash:
http://www.php.net/bugs-generating-backtrace.php

--Jani


 [2001-03-21 22:35 UTC] tdavis at birddg dot com
NOTE!
I made a rather LARGE mistake and noted that it was the stable version of php when it was cvs.  I appologize for this!  I noted the cvs version by date and time above.  I just updated via cvs to see if it was fixed.  Here is the backtrace none the less.

Hopefully this is what you need.  Thank you!

=================
START
=================
This GDB was configured as "i386-slackware-linux"...
(gdb) run -X
Starting program: /usr/local/apache/bin/httpd -X
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.

Program received signal SIGSEGV, Segmentation fault.
0x0 in ?? ()
(gdb) bt
#0  0x0 in ?? ()
#1  0x422f19e8 in ?? ()
#2  0x422eb50a in ?? ()
#3  0x422d546b in ?? ()
#4  0x422d5620 in ?? ()
#5  0x422d5866 in ?? ()
#6  0x401735bc in getprotobyname_r () from /lib/libc.so.6
#7  0x40173438 in getprotobyname () from /lib/libc.so.6
#8  0x81f6679 in tcp_socket_open (sin=0xbfffa060, tmp=0xbfff9860 "?\032",
    ctr=0xbfff985c, hst=0xbfff9c60 "mail.tconl.com", port=110)
    at tcp_unix.c:230
#9  0x81f6531 in tcp_open (host=0xbfffa508 "mail.tconl.com", service=0x0,
    port=110) at tcp_unix.c:183
#10 0x81f02f1 in net_open_work (dv=0x83eab80,
    host=0xbfffa508 "mail.tconl.com", service=0xbfffa88a "pop3", port=110,
    portoverride=110, flags=0) at mail.c:5523
#11 0x81f02a7 in net_open (mb=0xbfffa508, dv=0x0, port=110, ssld=0x0,
    ssls=0x83ba084 "*pop3s", sslp=995) at mail.c:5494
#12 0x820f6ba in pop3_open (stream=0x855a0a0) at pop3.c:328
#13 0x81e5845 in mail_open (stream=0x0,
    name=0x8447d94 "{mail.tconl.com:110/pop3}", options=0) at mail.c:1019
#14 0x80cb04f in imap_do_open (ht=3, return_value=0x856221c, this_ptr=0x0,
    return_value_used=1, persistent=0) at php_imap.c:809
---Type <return> to continue, or q <return> to quit---
#15 0x80cb146 in php_if_imap_open (ht=3, return_value=0x856221c, this_ptr=0x0,
    return_value_used=1) at php_imap.c:837
#16 0x819d223 in execute (op_array=0x84da40c) at ./zend_execute.c:1494
#17 0x819d3f4 in execute (op_array=0x84a2794) at ./zend_execute.c:1534
#18 0x816533f in zend_execute_scripts (type=8, file_count=3) at zend.c:743
#19 0x80be2bc in php_execute_script (primary_file=0xbffff84c) at main.c:1194
#20 0x8175c2b in apache_php_module_main (r=0x8489d10, display_source_mode=0)
    at sapi_apache.c:89
#21 0x80bb3fa in send_php ()
#22 0x80bb42c in send_parsed_php ()
#23 0x81a7973 in ap_invoke_handler ()
#24 0x81bb701 in process_request_internal ()
#25 0x81bb760 in ap_process_request ()
#26 0x81b2d81 in child_main ()
#27 0x81b2f2c in make_child ()
#28 0x81b3087 in startup_children ()
#29 0x81b36bc in standalone_main ()
#30 0x81b3e4f in main ()
#31 0x400cc577 in __libc_start_main () from /lib/libc.so.6
(gdb)
 [2001-03-21 23:45 UTC] tdavis at birddg dot com
also, please note that my email address is
tdavis@birddog.com   

I made a typo when I submitted it originally.
Thank you again,
Terry
 [2001-03-22 08:06 UTC] sniper@php.net
Please open a new bug report with correct email address.
And before doing that, generate a proper backtrace,
ie. add the --enable-debug into your configure line.

1. delete config.cache
2. run configure (with your options + --enable-debug)
3. make clean ; make ; make install


--Jani

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 02:01:30 2024 UTC