Stack backtrace on fatal error?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Tyler

    #1

    Stack backtrace on fatal error?

    I'm getting fatal errors when executing code - and my error handler is
    failing to trap them - so I get no stack backtrace :-(

    The error I am getting is:

    "Fatal error: Call to a member function fetchRow() on a non-object."

    What are the available options here?

    Am I supposed to check I have a real object whenever I perform
    a method call - or run the risk of getting runtime errors which
    give few clues about where the functions they are in are being
    called from?

    Is there some way of beefing up the error handler so that
    "fatal errors" can be trapped - without using a customised
    PHP parser at runtime?
    --
    __________
    |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.
  • Andy Hassall

    #2
    Re: Stack backtrace on fatal error?

    On Fri, 17 Sep 2004 12:11:04 GMT, Tim Tyler <tim@tt1lock.or g> wrote:
    [color=blue]
    >I'm getting fatal errors when executing code - and my error handler is
    >failing to trap them - so I get no stack backtrace :-(
    >
    >The error I am getting is:
    >
    >"Fatal error: Call to a member function fetchRow() on a non-object."[/color]

    Looks like a bug to me, this ought to go to the user defined error handler.
    Have you checked bugs.php.net?

    Attempts to get a property of a non-object goes through the user defined error
    handler from a quick test, but not method calls.

    --
    Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
    <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

    Comment

    • Tim Tyler

      #3
      Re: Stack backtrace on fatal error?

      Andy Hassall <andy@andyh.co. uk> wrote or quoted:[color=blue]
      > On Fri, 17 Sep 2004 12:11:04 GMT, Tim Tyler <tim@tt1lock.or g> wrote:[/color]
      [color=blue][color=green]
      > >I'm getting fatal errors when executing code - and my error handler is
      > >failing to trap them - so I get no stack backtrace :-(
      > >
      > >The error I am getting is:
      > >
      > >"Fatal error: Call to a member function fetchRow() on a non-object."[/color]
      >
      > Looks like a bug to me, this ought to go to the user defined error handler.
      > Have you checked bugs.php.net?[/color]

      There they say that thay can't continue from fatal errors - because
      the Zend engine has got its knickers in a twist by that stage -
      but they /do/ also say:

      ``Fatal errors are fatal for a reason although there are some feature
      change requests to separate out Zend fatals (which will never be
      catchable) and PHP Fatal errors which maybe oneday we can make
      catchable.''

      - http://bugs.php.net/bug.php?id=9384

      Another supposedly-fatal error: "Call to undefined function" :-(
      --
      __________
      |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.

      Comment

      • R. Rajesh Jeba Anbiah

        #4
        Re: Stack backtrace on fatal error?

        Tim Tyler <tim@tt1lock.or g> wrote in message news:<I46puG.6w o@bath.ac.uk>.. .
        <snip>[color=blue]
        > Is there some way of beefing up the error handler so that
        > "fatal errors" can be trapped - without using a customised
        > PHP parser at runtime?[/color]

        Custom error handler cannot handle the fatal errors; you need to do
        the output buffering techniques. Look at the manual and user note
        <http://in.php.net/set_error_handl er#35622> When you use output
        buffering, you cannot again use highlight_strin g(). I have written a
        custom error handler to handle all these situations; as it is
        proprietary, I cannot outsource it now.

        HTH.

        --
        | Just another PHP saint |
        Email: rrjanbiah-at-Y!com

        Comment

        • Tim Tyler

          #5
          Re: Stack backtrace on fatal error?

          R. Rajesh Jeba Anbiah <ng4rrjanbiah@r ediffmail.com> wrote or quoted:[color=blue]
          > Tim Tyler <tim@tt1lock.or g> wrote in message news:<I46puG.6w o@bath.ac.uk>.. .[/color]
          [color=blue][color=green]
          > > Is there some way of beefing up the error handler so that
          > > "fatal errors" can be trapped - without using a customised
          > > PHP parser at runtime?[/color]
          >
          > Custom error handler cannot handle the fatal errors; you need to do
          > the output buffering techniques. Look at the manual and user note
          > <http://in.php.net/set_error_handl er#35622> When you use output
          > buffering, you cannot again use highlight_strin g(). I have written a
          > custom error handler to handle all these situations; as it is
          > proprietary, I cannot outsource it now.[/color]

          Interesting - thanks.

          Unfortunately, calling debug_backtrace () within the fatal error handler
          seems to produce one function call - to the fatal error handler itself -
          so this approach does not seem effective at getting hold of backtrace
          information for the fatal error - and getting hold of that information
          was the main reason I was interested in trapping the error in the first
          place.
          --
          __________
          |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.

          Comment

          • Chris Hope

            #6
            Re: Stack backtrace on fatal error?

            Tim Tyler wrote:
            [color=blue]
            > "Fatal error: Call to a member function fetchRow() on a non-object."[/color]

            It means that you've done eg $foo->fetchRow() but $foo is not actually an
            object. Without seeing any of your code it is difficult to further diagnose
            what your problem is.

            --
            Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/

            Comment

            • Tim Tyler

              #7
              Re: Stack backtrace on fatal error?

              Chris Hope <blackhole@elec trictoolbox.com > wrote or quoted:[color=blue]
              > Tim Tyler wrote:[/color]
              [color=blue][color=green]
              > > "Fatal error: Call to a member function fetchRow() on a non-object."[/color]
              >
              > It means that you've done eg $foo->fetchRow() but $foo is not actually an
              > object. Without seeing any of your code it is difficult to further diagnose
              > what your problem is.[/color]

              I was not trying to fix that problem - it was an example.

              I was trying to find a better way of fixing *all* such bugs -
              by getting PHP to report where the problem code was called from.
              --
              __________
              |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.

              Comment

              • Tim Tyler

                #8
                Re: Stack backtrace on fatal error?

                R. Rajesh Jeba Anbiah <ng4rrjanbiah@r ediffmail.com> wrote or quoted:[color=blue]
                > Tim Tyler <tim@tt1lock.or g> wrote in message news:<I48AK9.A0 6@bath.ac.uk>.. .[/color]
                [color=blue][color=green]
                > > Unfortunately, calling debug_backtrace () within the fatal error handler
                > > seems to produce one function call - to the fatal error handler itself -
                > > so this approach does not seem effective at getting hold of backtrace
                > > information for the fatal error - and getting hold of that information
                > > was the main reason I was interested in trapping the error in the first
                > > place.[/color]
                >
                > For me, it is working (4.3.4).[/color]

                Hmm. I may try again someday.

                It's a "dreadful hack" - but it /would/ be helpful if I could get it to work.
                --
                __________
                |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.

                Comment

                • R. Rajesh Jeba Anbiah

                  #9
                  Re: Stack backtrace on fatal error?

                  Tim Tyler <tim@tt1lock.or g> wrote in message news:<I4CyMz.1x z@bath.ac.uk>.. .[color=blue]
                  > R. Rajesh Jeba Anbiah <ng4rrjanbiah@r ediffmail.com> wrote or quoted:[color=green][color=darkred]
                  > > > Unfortunately, calling debug_backtrace () within the fatal error handler
                  > > > seems to produce one function call - to the fatal error handler itself -
                  > > > so this approach does not seem effective at getting hold of backtrace
                  > > > information for the fatal error - and getting hold of that information
                  > > > was the main reason I was interested in trapping the error in the first
                  > > > place.[/color]
                  > >
                  > > For me, it is working (4.3.4).[/color]
                  >
                  > Hmm. I may try again someday.
                  >
                  > It's a "dreadful hack" - but it /would/ be helpful if I could get it to work.[/color]

                  There is a popular ErrorHandler class
                  <http://www.phpclasses. org/ErrorHandler>. Unfortunately, it didn't
                  attract me much, probably it may be useful to you. They trap so many
                  errors with additional JS.

                  --
                  | Just another PHP saint |
                  Email: rrjanbiah-at-Y!com

                  Comment

                  Working...