Page MenuHomePhabricator

AphrontWriteGuard was not properly disposed of
Closed, ResolvedPublic

Description

I'm seeing the following error a bunch of times in our error logs:

/usr/src/libphutil/src/utils/utils.php:241


┻━┻ ︵ ¯\_(ツ)_/¯ ︵ ┻━┻
[23-Jul-2014 23:43:01 UTC] PHP Fatal error:  Uncaught exception 'Exception' with message 'AphrontWriteGuard was not properly disposed of! Call dispose() on every AphrontWriteGuard object you instantiate or use phutil_exit() to exit abruptly while debugging.' in /usr/src/libphutil/src/aphront/writeguard/AphrontWriteGuard.php:280
Stack trace:
#0 [internal function]: AphrontWriteGuard->__destruct()
#1 {main}
  thrown in /usr/src/libphutil/src/aphront/writeguard/AphrontWriteGuard.php on line 280
[23-Jul-2014 23:48:34 UTC] PHP Fatal error:  Uncaught exception 'Exception' with message 'AphrontWriteGuard was not properly disposed of! Call dispose() on every AphrontWriteGuard object you instantiate or use phutil_exit() to exit abruptly while debugging.' in /usr/src/libphutil/src/aphront/writeguard/AphrontWriteGuard.php:280
Stack trace:
#0 [internal function]: AphrontWriteGuard->__destruct()
#1 {main}
  thrown in /usr/src/libphutil/src/aphront/writeguard/AphrontWriteGuard.php on line 280

Event Timeline

joshuaspence assigned this task to epriestley.
joshuaspence raised the priority of this task from to Needs Triage.
joshuaspence updated the task description. (Show Details)
joshuaspence added projects: Aphront, Phabricator.
joshuaspence added a subscriber: joshuaspence.

This normally happens after some other error. Is there anything else which might be the primary cause?

Not really...

[24-Jul-2014 10:35:58 UTC] [2014-07-24 20:35:58] ERROR 8: Undefined offset: 365 at [/usr/src/phabricator/src/applications/differential/parser/DifferentialHunkParser.php:99]
[24-Jul-2014 10:35:58 UTC]   #0 DifferentialHunkParser::setOldLineTypeMap(array) called at [<phabricator>/src/applications/differential/parser/DifferentialChangesetParser.php:582]
[24-Jul-2014 10:35:58 UTC]   #1 DifferentialChangesetParser::process() called at [<phabricator>/src/applications/differential/parser/DifferentialChangesetParser.php:512]
[24-Jul-2014 10:35:58 UTC]   #2 DifferentialChangesetParser::tryCacheStuff() called at [<phabricator>/src/applications/differential/parser/DifferentialChangesetParser.php:742]
[24-Jul-2014 10:35:58 UTC]   #3 DifferentialChangesetParser::render(NULL, NULL, array) called at [<phabricator>/src/applications/differential/controller/DifferentialChangesetViewController.php:217]
[24-Jul-2014 10:35:58 UTC]   #4 DifferentialChangesetViewController::processRequest() called at [<phabricator>/webroot/index.php:95]
[24-Jul-2014 10:35:58 UTC] [2014-07-24 20:35:58] ERROR 8: Undefined offset: 496 at [/usr/src/phabricator/src/applications/differential/parser/DifferentialHunkParser.php:120]
[24-Jul-2014 10:35:58 UTC]   #0 DifferentialHunkParser::setNewLineTypeMap(array) called at [<phabricator>/src/applications/differential/parser/DifferentialChangesetParser.php:583]
[24-Jul-2014 10:35:58 UTC]   #1 DifferentialChangesetParser::process() called at [<phabricator>/src/applications/differential/parser/DifferentialChangesetParser.php:512]
[24-Jul-2014 10:35:58 UTC]   #2 DifferentialChangesetParser::tryCacheStuff() called at [<phabricator>/src/applications/differential/parser/DifferentialChangesetParser.php:742]
[24-Jul-2014 10:35:58 UTC]   #3 DifferentialChangesetParser::render(NULL, NULL, array) called at [<phabricator>/src/applications/differential/controller/DifferentialChangesetViewController.php:217]
[24-Jul-2014 10:35:58 UTC]   #4 DifferentialChangesetViewController::processRequest() called at [<phabricator>/webroot/index.php:95]
[24-Jul-2014 10:36:24 UTC] PHP Fatal error:  Uncaught exception 'Exception' with message 'AphrontWriteGuard was not properly disposed of! Call dispose() on every AphrontWriteGuard object you instantiate or use phutil_exit() to exit abruptly while debugging.' in /usr/src/libphutil/src/aphront/writeguard/AphrontWriteGuard.php:280
Stack trace:
#0 [internal function]: AphrontWriteGuard->__destruct()
#1 {main}
  thrown in /usr/src/libphutil/src/aphront/writeguard/AphrontWriteGuard.php on line 280
[24-Jul-2014 10:48:43 UTC] PHP Fatal error:  Uncaught exception 'Exception' with message 'AphrontWriteGuard was not properly disposed of! Call dispose() on every AphrontWriteGuard object you instantiate or use phutil_exit() to exit abruptly while debugging.' in /usr/src/libphutil/src/aphront/writeguard/AphrontWriteGuard.php:280
Stack trace:
#0 [internal function]: AphrontWriteGuard->__destruct()
#1 {main}
  thrown in /usr/src/libphutil/src/aphront/writeguard/AphrontWriteGuard.php on line 280
[24-Jul-2014 10:48:44 UTC] PHP Fatal error:  Uncaught exception 'Exception' with message 'AphrontWriteGuard was not properly disposed of! Call dispose() on every AphrontWriteGuard object you instantiate or use phutil_exit() to exit abruptly while debugging.' in /usr/src/libphutil/src/aphront/writeguard/AphrontWriteGuard.php:280
Stack trace:
#0 [internal function]: AphrontWriteGuard->__destruct()
#1 {main}
  thrown in /usr/src/libphutil/src/aphront/writeguard/AphrontWriteGuard.php on line 280
[24-Jul-2014 11:33:16 UTC] PHP Fatal error:  Uncaught exception 'Exception' with message 'AphrontWriteGuard was not properly disposed of! Call dispose() on every AphrontWriteGuard object you instantiate or use phutil_exit() to exit abruptly while debugging.' in /usr/src/libphutil/src/aphront/writeguard/AphrontWriteGuard.php:280
Stack trace:
#0 [internal function]: AphrontWriteGuard->__destruct()
#1 {main}
  thrown in /usr/src/libphutil/src/aphront/writeguard/AphrontWriteGuard.php on line 280
[24-Jul-2014 12:20:44 UTC] PHP Fatal error:  Uncaught exception 'Exception' with message 'AphrontWriteGuard was not properly disposed of! Call dispose() on every AphrontWriteGuard object you instantiate or use phutil_exit() to exit abruptly while debugging.' in /usr/src/libphutil/src/aphront/writeguard/AphrontWriteGuard.php:280
Stack trace:
#0 [internal function]: AphrontWriteGuard->__destruct()
#1 {main}
  thrown in /usr/src/libphutil/src/aphront/writeguard/AphrontWriteGuard.php on line 280

Hrrm. Maybe we could initialize AphrontWriteGuard with an identifying string (e.g., URL) to make this easier to debug.

FWIW, I'm seeing this roughly 60 times per day in our error logs.

I've removed this error completely (see rPHUbd087f55).

Specifically, this caused a health check failure in the Phacility cluster after exit(0); from /status/. Worse, the 500 it produced didn't show up in the logs. I was able to guess the root cause relatively quickly, but this was some bad mojo.

Generally, this error is problematic for two reasons:

  • When some other error causes an abrupt exit, this can show up in logs as a side effect (likely, as here). In this situation, the WriteGuard error is not diagnostically useful and not the root cause. This is confusing to users and makes support much difficult.
  • We don't actually care that WriteGuards all get disposed. Not disposing a WriteGuard just means that some writes might fail (in an explicit, obvious way). In practice, I don't think this has ever happened because of an undisposed WriteGuard. Concretely, the problems caused by warning about this are far greater than the (minor, obvious, easily rectified) programming mistakes it might occasionally catch, in theory.

I filed T8219 to track removing the phutil_exit() function, which is a remnant of this error.