絖綛 N@i.jp  昨日:00000000
 今日:00012076
 総計:00012076
keywords
管理者専用
  Post   Add link   Control Panel 































新しいトピック
最新:04/16 19:55


新しいコメント
最新:07/28 16:47






管理人へMAIL

プライバシーポリシー

PHP 8系に移行できるだろうか?(6)

PHPスクリプトをPHP8互換に修正しても Apache子プロセスの異常終了は直らなかったよ


 ウチの BlogのPHPスクリプトなんですが、一応互換性チェックはパスしまして、phpコマンドでは以下のとおり正常にホームページの HTMLを返して来るんですよ。

$ /usr/local/php8/bin/php ./index.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-JP" name="viewport" content="width=device-width, initial-scale=1.0">
<LINK REL="SHORTCUT ICON" type="image/x-icon" href="template/nai/images/favicon.ico">
<Link Rel="stylesheet" href="./css/foundation.css">
<LINK title="RSS" href="http://y-naito.ddo.jp/syndicate/syndicate.php" type="application/rss+xml" rel="alternate">
<title>N@i.jp</title>
<style type="text/css" media="screen">
    〜略〜
</style>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
    〜略〜
</table>
</body>
</html>

なのでホームページの表示は出来ているのだけど、Apacheのエラーログを見ると、

[Wed Feb 08 13:43:14.992156 2023] [mpm_worker:notice] [pid 15187:tid 2684415368] AH00292: Apache/2.4.55 (Unix) PHP/8.0.27 OpenSSL/1.1.1s SVN/1.13.0 configured -- resuming normal operations
[Wed Feb 08 13:43:14.992755 2023] [core:notice] [pid 15187:tid 2684415368] AH00094: Command line: '/usr/local/apache2/bin/httpd'
[Wed Feb 08 13:44:11.011782 2023] [core:notice] [pid 15187:tid 2684415368] AH00052: child pid 15191 exit signal Bus error (10)
[Wed Feb 08 13:44:30.015720 2023] [core:notice] [pid 15187:tid 2684415368] AH00052: child pid 15189 exit signal Bus error (10)
[Wed Feb 08 13:45:41.037851 2023] [core:notice] [pid 15187:tid 2684415368] AH00052: child pid 15190 exit signal Bus error (10)

こんな具合に子プロセスがSIGBUSで落ちまくるんです。なので、リクエストが来る度に Apacheが子プロセスを生成し、表示し終わると(あるいは表示途中に)落ちるを繰り返しているという状態なわけね。これじゃ運用に堪えないです。

 異常終了するのは Apacheの子プロセスとして動いた場合だけなので、Apacheの子プロセスに gdbをアタッチして動かしてみたら、概ね以下の経路で異常終了するようです。

# gdb -p 8070
GNU gdb 6.3.50-20050815 (Apple version gdb-573) (Fri Oct 20 15:54:33 GMT 2006)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-apple-darwin".
/usr/local/8070: No such file or directory.
Attaching to process 8070.
Reading symbols for shared libraries . done
Reading symbols for shared libraries ................................................................................................................... done
0x900144a4 in read ()
(gdb) c
Continuing.

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000010
[Switching to process 8070 thread 0x7c03]
0x90002dc8 in strlen ()
(gdb) where
#0  0x90002dc8 in strlen ()
#1  0x90017918 in strdup ()
#2  0x03bc6dc4 in php_error_cb ()
#3  0x03bc98ac in zend_error_impl ()
#4  0x03bca048 in zend_error_zstr ()
#5  0x03bc78e8 in php_verror ()
#6  0x03bc7a54 in php_error_docref ()
#7  0x0386703c in OnUpdate_mbstring_internal_encoding ()
#8  0x03b2b3f8 in zend_alter_ini_entry_ex ()
#9  0x03b2b5f4 in zend_alter_ini_entry_chars ()
#10 0x03b54480 in apply_config ()
#11 0x03b53058 in php_handler ()
#12 0x0001a2b0 in ap_run_handler ()
#13 0x0001a988 in ap_invoke_handler ()
#14 0x000434c4 in ap_process_async_request ()
#15 0x00043650 in ap_process_request ()
#16 0x000421c0 in ap_process_http_connection ()
#17 0x00034660 in ap_run_process_connection ()
#18 0x0004e134 in worker_thread ()
#19 0x9002b908 in _pthread_body ()
(gdb)

何となくエラーメッセージを出そうとしているような感じ。その際に 0x00000010 なんていうアドレスを触ろうとしているようですね。こんな場所がデータ領域なわけないです(SIGBUS よりも SIGSEGVの方が的確なんじゃ?)。
 ソースで言うと、"main/main.c" の以下の場所かと。

static ZEND_COLD void php_error_cb(int orig_type, const char *error_filename, const uint32_t error_lineno, zend_string *message)
{
    〜略〜
    /* store the error if it has changed */
    if (display) {
        clear_last_error();
        if (!error_filename) {
            error_filename = "Unknown";
        }
        PG(last_error_type) = type;
        PG(last_error_message) = zend_string_copy(message);
        PG(last_error_file) = strdup(error_filename);
        PG(last_error_lineno) = error_lineno;
    }
    〜略〜
}

php_error_cb の中で strdup() を呼んでいるのはココだけなので間違いないかと。引数 error_filename に文字列ではないアドレス 0x00000010 が渡されて来ているのでしょうな。う〜ん、これだけ見るとバグっぽいなぁ。


< 過去の記事 [ 2月の 全てのカテゴリ リスト ] 新しい記事 >

2023 calendar
2月
1234
567891011
12131415161718
19202122232425
262728


掲示板
最新:08/15 17:19


GsBlog was developed by GUSTAV, Copyright(C) 2003, Web Application Factory All Rights Reserved.