Forum Moderators: phranque

Message Too Old, No Replies

Recovering from segmentation fault

I was debugging infinite recursion in PHP.

         

Jesdisciple

9:22 am on Jun 11, 2009 (gmt 0)

10+ Year Member



I was debugging infinite recursion in PHP, and suddenly Apache stopped serving all pages except index.php. I restarted Apache and Ubuntu - no luck. What can I do to use my server again?

Thanks.

jdMorgan

6:08 pm on Jun 11, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"All pages except index.php"

So does your index.php use a database to generate all of the other pages? If so, then the database may be out of 'record handles' due to the previous recursion problem and will also need to be restarted.

If this were Windows, I'd say "shut down and restart the machine." That might also be a good idea here if you are not sure what other applications and services your site depends on in addition to the OS and APache.

BTW, this answer is just a guess. But you have likely "used up" all of "some kind of thing" somewhere, and need to force deallocation of "those things" to restore proper operation. Those "things" might be DB records, pointers, indexes, key handles, or files... I dunno.

Jim

Jesdisciple

6:22 pm on Jun 11, 2009 (gmt 0)

10+ Year Member



No, index.php seems to be from Apache's cache; it reports an error in a file that I stopped using yesterday and doesn't respond to changes. No DB is used yet.

I recall that I once had problems with CSS files getting "stuck" in Apache's cache, and I never got a solution for this. The problem eventually went away, but now that solution would again be useful.

As I was debugging, memory usage gradually rose each time I refreshed the page until the server apparently had nothing to work with.

Jesdisciple

11:48 pm on Jun 11, 2009 (gmt 0)

10+ Year Member



Woops, I'm wrong for about the hundredth time this week. I was looking at my deployment server, which uses a similar domain.

The pages are being served; they do respond to changes, but only to report errors. No real output comes out...?

EDIT: This is getting pretty weird. I do use output buffering on this page, so I thought maybe commenting that would help - it didn't. Triggering an error with require() does force some real output.

Also, pages requested with the .php extension are sent via FTP instead of HTTP.

[edited by: Jesdisciple at 12:01 am (utc) on June 12, 2009]

Jesdisciple

2:54 am on Jun 12, 2009 (gmt 0)

10+ Year Member



Update: I just thought to check, and sure enough I get a segfault every time I request a page, even if it's sent over FTP.

Jesdisciple

6:53 pm on Jun 12, 2009 (gmt 0)

10+ Year Member



I've further determined that this is only a problem with one vhost. On plain ol' localhost, 404 errors are reported by Firefox as "Cannot Complete Request ... Additional information about this problem or error is currently unavailable."

EDIT: So I tried to debug my page from localhost/test.php. When I finally managed to set the DOCUMENT_ROOT correctly so the included page could run, the problem spread to the new page. Breaking the DOCUMENT_ROOT allowed the page to work again.

[edited by: Jesdisciple at 7:03 pm (utc) on June 12, 2009]

jdMorgan

7:14 pm on Jun 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This problem is so odd that I can't think of anything to suggest. :(

Something, somewhere, is seriously mis-configured. The comment you made about resources being requested via HTTP being served by FTP is really, really strange. I've never heard of anything like that before.

I just didn't want you to think your thread was being ignored...

Jim

Jesdisciple

9:18 pm on Jun 12, 2009 (gmt 0)

10+ Year Member



My previous post indicated that the problem was in the PHP and Apache was somehow reacting to it. I think the difference between the very long outputs and the complete lack of output was in the type of infinite recursion.

While I was seeing the long outputs, my attempt to solve them resulted in the recursive function being called with the exact same arguments every time, rather than a slightly longer string. The server apparently recognized this recursion as infinite and bailed.

By commenting progressively more specific lines of code and noting when I got output, I was finally able to debug the code and chop the root of recursion.

[edited by: Jesdisciple at 9:19 pm (utc) on June 12, 2009]