We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon 2.0: Segmentation fault, empty response

Randomly, a Phalcon 2.0 application returns empty response. After retrying, without changing any code or input, I get a response.

I have two subdomains on the same physical machine. The first subdomain is a frontend API, and the second is a backend API. The frontend calls the backend over HTTP (not HTTPS) using CURL. Approximately 2/3 of the calls come back empty. When I retry 2 or 3 times, I get a response. The problem is less pronounced when I access the backend directly, and more pronounced when I access the frontend and it in turn calls the backend before responding. Depending on which of the two subdomans failed, I get either an empty response from the frontend, or an error "Empty reply from server" when the internal call to the backend service comes back empty.

Cache-Control header set to no-cache, and curl option CURLOPT_FRESH_CONNECT set to true don't have any effect.

Apache error log shows the following when the error occurs:

[core:notice] [pid 7062] AH00052: child pid 7070 exit signal Segmentation fault (11)

7070 is the process of the currently executing request.

On several occasions, I also noticed the index.php being executed twice back-to-back.

My application works fine with Phalcon 1.3.4.

My configuration: Apache 2.4 and PHP 5.5.9 on Linux Mint 64-bit running in a VMWare virtual machine with 4 GB of memory and 4 CPU cores.

Thank you for your help.

-Stan

UPDATE: I don't believe it is any of these already reported issues:

https://github.com/phalcon/cphalcon/issues/10126

https://github.com/phalcon/cphalcon/issues/2269

If I retry, it would eventually work without me changing any code, settings, or input.

Could you please post a script that allow us to reproduce the issue?

Same problem here. how does one debug these problems?

the problem disapper on server restart though

Could you please post a script that allow us to reproduce the issue?

Same problem here. how does one debug these problems?

Code available here https://bitbucket.org/faizmh/phalcontest Deployed here https://phalcontest.azurewebsites.net/

Phalcon Author Phalcon Team and contributors Version 2.0.7 Build Date Aug 17 2015 14:25:34 Powered by Zephir Version 0.7.1b

PHPINFO Compiler MSVC9 (Visual C++ 2008) Architecture x86 Zend Extension Build API220100525,NTS,VC9

issue not reproducible now. Please check the code. I will report back once I find the problem

edited Sep '15

How do you know you're having a segmentation fault?, this concept does not exactly exist on Windows. Also, what steps do I have to follow to see the problem?

edited Sep '15

sorry. I was referring to Approximately 2/3 of the calls come back empty. When I retry 2 or 3 times, I get a response. This was happening when I was on IIS/Windows. The response were blank and 200 OK.

  1. Home https://phalcontest.azurewebsites.net/
  2. Login
  3. Access Logged in resource

step 3 would give intermediate blank response. (although not happening now. I will wait for another 2 weeks to update you on the result)

recevied the same blank response once again; and this gets worse once you are in production environment

So how does one debug these problems, there is no error in php log. Its a shame to get handicapped and relying on a forum with limited help

I followed your steps, it never gives me a blank page

I just have fiddler sessions to back my claim. no php error logs. Andres, how can I debug? what should I enable? if you could skype or team viewer, I could just show them. the issue resolves on server restart

edited Sep '15

Could you please run ab against your host?

ab -n 100 -c 3 https://phalcontest.azurewebsites.net/sec/test
This is ApacheBench, Version 2.3 <$Revision: 1663405 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, https://www.zeustech.net/
Licensed to The Apache Software Foundation, https://www.apache.org/

Benchmarking phalcontest.azurewebsites.net (be patient).....done

Server Software:        Microsoft-IIS/8.0
Server Hostname:        phalcontest.azurewebsites.net
Server Port:            80

Document Path:          /sec/test
Document Length:        156 bytes

Concurrency Level:      3
Time taken for tests:   19.754 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      75700 bytes
HTML transferred:       15600 bytes
Requests per second:    5.06 [#/sec] (mean)
Time per request:       592.631 [ms] (mean)
Time per request:       197.544 [ms] (mean, across all concurrent requests)
Transfer rate:          3.74 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:      281  282   4.1    282     322
Processing:   287  304  60.5    290     797
Waiting:      287  302  44.7    290     612
Total:        568  587  61.1    572    1083

Percentage of the requests served within a certain time (ms)
  50%    572
  66%    574
  75%    575
  80%    576
  90%    607
  95%    677
  98%    824
  99%   1083
 100%   1083 (longest request)
edited Sep '15

Blank response once again.

C:\wamp\bin\apache\Apache2.4.4\bin>ab -n 100 -c 3 https://xxx.azurewebsites.net/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, https://www.zeustech.net/
Licensed to The Apache Software Foundation, https://www.apache.org/

Benchmarking xxx.azurewebsites.net (be patient).....done

Server Software:        Microsoft-IIS/8.0
Server Hostname:        xxx.azurewebsites.net
Server Port:            80

Document Path:          /
Document Length:        100617 bytes

Concurrency Level:      3
Time taken for tests:   64.737 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      10102500 bytes
HTML transferred:       10061700 bytes
Requests per second:    1.54 [#/sec] (mean)
Time per request:       1942.101 [ms] (mean)
Time per request:       647.367 [ms] (mean, across all concurrent requests)
Transfer rate:          152.40 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       64  465 990.3    100    3265
Processing:   485 1468 1274.4    782    4144
Waiting:       82  364 718.7    154    3269
Total:        582 1933 1512.6    921    6768

Percentage of the requests served within a certain time (ms)
  50%    921
  66%   3589
  75%   3756
  80%   3796
  90%   3929
  95%   3986
  98%   4524
  99%   6768
 100%   6768 (longest request)

Failed requests: 0 Write errors: 0

the ab test was after I restarted the servers. Mind you these are production servers and I have to restart them immediately

Also please note during failures, the responses are always 200 OK Content-Length: 0 Content-Type: text/html

eventhough these failed responses are supposed to return content with json content-type

How do I tracing? shall I introduce some tracing code into my php to troubleshoot? It seems I will face this problem again in 48hrs