Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#16340 closed defect (duplicate)

PHP throwing fork()ing error

Reported by: cabanela@… Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 1.6.0
Keywords: Cc:
Port:

Description

Honestly, I think this error is in the OS (or its origin is), but I am sitting here pulling my hair out.

I have several PHP scripts that call a PHP package called JpGraph to generate graphs. I should not I had been using Apple's built-in PHP and APache servers. Since upgrading to Leopard, the following error is recorded in the Apache2 error_log

The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.

I discovered that the PDFLIb folks have documented this problem a little better, copying from their documentation here

http://www.pdflib.com/fileadmin/pdflib/pdf/support/PDFlib-in-PHP-HowTo.pdf

Apple’s PHP version which is bundled with Mac OS X does not work with PDFlib DSOs. To use PHP with PDFlib on Mac OS X you need third-party PHP packages such as MAMP, XAMP[P] for Mac, or Marc Liyanage’s version from www.entropy.ch. Mac OS X 10.5 (Leopard) adds new complications. As described in developer.apple.com/releasenotes/CoreFoundation/CoreFoundation.html it is no longer possible to use CoreFoundation functions after a call to fork( ) without exec( ). However, CoreFoundation functions are required for PDFlib’s host font feature, and the critical sequence above is used in the combination of Apache and PHP.

I went ahead and installed Apache2 and PHP5 via MacPorts and configured them properly and discovered to my joy that my old graphics generating scripts were working... for 48 hours. My Mac locked up over the weekend (not sure why, it was the first time, maybe related), and when I reboot, I discovered now that the MacPorts PHP installation is now tossing the same errors.

This has really confused me:

  1. Can someone explain if the PDFLib folks were correct that you could avoid these errors with a non-Apple PHP installation or is this an unavoidable OS feature (which would make sense, I suppose)?
  1. If this is avoidable, can someone with more PHP knowledge than me explain how to configure PHP to avoid "forking" in a manner offensive to Apple?

Change History (8)

comment:1 Changed 16 years ago by cabanela@…

I should note I have confirmed the JpGraph PHP library doesn't call fork(), this is something going on inside the PHP code as near as I can tell.

comment:2 Changed 16 years ago by cabanela@…

As I just noted on my blog:

I've continued investigating and in Apple's Discussion boards I found there was a string of comments about this problem (--http://discussions.apple.com/thread.jspa?messageID=5693097#5961098--) . One user, Bill Eccles, seemed to isolate the problem and his description matches the symptoms I am seeing:

Finally, there's a big problem with FreeType. As I discovered, anytime FreeType fonts are used by GD, they apparently make a Carbon API call of some sort. Problem is, Apache2 uses fork() without a corresponding exec() and, upon calling PHP/GD/FreeType, the Carbon call in FreeType causes Apache2 to crash. It shows up in the error_log as

The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec(). Break on THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY_YOU_MUST_EXEC() to debug. Mon Nov 26 12:38:11 2007 notice child pid 304 exit signal Trace/BPT trap (5)

and in the system.log as

Nov 26 13:12:00 shr-g5 ReportCrash664: Formulating crash report for process httpd659 Nov 26 13:12:02 shr-g5 ReportCrash664: Saved crashreport to /Library/Logs/CrashReporter/httpd_2007-11-26-131145_shr-g5.crash using uid: 0 gid: 0, euid: 0 egid: 0

I didn't discover the cause--I can't take credit for this one. Here's where I discovered the FreeType/Apache2 problem:

http://spteam-lists.blogspot.com/2007/11/freetype-digest-vol-35-issue-1.html

The followup comment suggests a solution by compiling a replacement to Apple's built-in Freetype to version 2.3.5. Funny thing is I have MacPorts Freetype 2.3.7 installed. Any ideas?

comment:3 Changed 16 years ago by jmroot (Joshua Root)

Milestone: Port Bugs
Owner: changed from macports-tickets@… to ryandesign@…

Assigning to maintainer (assuming this is about php5?)

comment:4 in reply to:  3 Changed 16 years ago by cabanela@…

Replying to jmr@macports.org:

Assigning to maintainer (assuming this is about php5?)

This actually turns out to be a freetype problem. I have re-filed it under Bug Report 16341 [actually, I am requesting the creation of a freetype variant] (https://trac.macports.org/ticket/16341). This is not a PHP problem.

comment:5 Changed 16 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: newclosed

Duplicate of #15909.

comment:6 Changed 16 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: closedreopened

comment:7 Changed 16 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: duplicate
Status: reopenedclosed

comment:8 Changed 15 years ago by (none)

Milestone: Port Bugs

Milestone Port Bugs deleted

Note: See TracTickets for help on using tickets.