New issue
Advanced search Search tips

Issue 915102 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Dec 17
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Bug



Sign in to add a comment

go runtime error: bad pointer

Project Member Reported by semenzato@chromium.org, Dec 14

Issue description

I don't think I am doing anything that's obviously illegal.
I am done for the evening so I am leaving everything alone in case I can get you anything off of the device.  (In any case, it's at 2401:fa00:480:c6:250:b6ff:fe63:83bf if you want to log on.)

2018/12/13 20:03:50 [20:03:50.589] Connecting to Chrome at ws://127.0.0.1:33440/devtools/page/12F8AA9ABE0C7F5F1BE9833FB6717EBE
2018/12/13 20:03:54 [20:03:54.181] Test API extension is ready
2018/12/13 20:03:54 [20:03:54.466] Creating new page with URL https://www.google.com/intl/en/drive/
2018/12/13 20:03:54 [20:03:54.554] Connecting to Chrome at ws://127.0.0.1:33440/devtools/page/EAF9851C19A2EF2C58F8776946466633
2018/12/13 20:03:58 [20:03:58.575] Error at stage.go:65: Panic: runtime error: invalid memory address or nil pointer dereference
2018/12/13 20:03:58 [20:03:58.575] Stack trace:
Panic
        at chromiumos/tast/testing.runAndRecover.func1.1 (stage.go:65)
        at runtime.call32 (asm_amd64.s:573)
        at runtime.gopanic (panic.go:502)
        at runtime.panicmem (panic.go:63)
        at runtime.sigpanic (signal_unix.go:388)
        at chromiumos/tast/local/bundles/cros/platform.addTabFromList (memory_pressure.go:196)
        at chromiumos/tast/local/bundles/cros/platform.MemoryPressure (memory_pressure.go:424)
        at chromiumos/tast/testing.(*Test).Run.func4 (test.go:208)
        ...
runtime error: invalid memory address or nil pointer dereference
2018/12/13 20:03:59 Completed test platform.MemoryPressure in 28.825s with 1 error(s)
2018/12/13 20:03:59 Copying /tmp/tast_out.749390480 from host to /tmp/tast/results/20181213-200325/out.tmp
2018/12/13 20:03:59 Cleaning /tmp/tast_out.749390480 on host
2018/12/13 20:03:59 Ran 1 local test(s) in 32.174s
2018/12/13 20:03:59 Collecting system information
2018/12/13 20:03:59 Copying /tmp/tast_logs.375471811 from host to /tmp/tast/results/20181213-200325/system_logs
2018/12/13 20:03:59 Cleaning /tmp/tast_logs.375471811 on host
2018/12/13 20:03:59 Copying /tmp/tast_crashes.438065478 from host to /tmp/tast/results/20181213-200325/crashes
2018/12/13 20:03:59 Cleaning /tmp/tast_crashes.438065478 on host
2018/12/13 20:04:00 --------------------------------------------------------------------------------
2018/12/13 20:04:00 platform.MemoryPressure  [ FAIL ] Panic: runtime error: invalid memory address or nil pointer dereference
2018/12/13 20:04:00 --------------------------------------------------------------------------------
2018/12/13 20:04:00 Results saved to /tmp/tast/results/20181213-200325
 
It happens every time!

Apparently it's related to this code:

func addTabFromList(ctx context.Context, s *testing.State,
        cr *chrome.Chrome, quiescenceCode string) (*renderer, error) {
        tab, err := addTab(ctx, s, cr, nextURL())
        if err != nil {
                return nil, err
        }
        err = tab.conn.Exec(ctx, quiescenceCode)
        if err != nil {
                return nil, errors.Wrap(err, "cannot inject quiescence code")
        }
        notQuiescedMsg := "tab did not quiesce within timeout"
        notQuiescedError := errors.New(notQuiescedMsg)
        err = testing.Poll(ctx, func(ctx context.Context) error {
                done := false
                err := evalPromiseBody(ctx, s, tab.conn,
                        "resolve(window.__telemetry_testHasReachedNetworkQuiescence())", &done)
                if err != nil {
                        return err
                }
                if !done {
                        return notQuiescedError
                }
                return nil
        }, &testing.PollOptions{
                Timeout:  15 * time.Second,
                Interval: 100 * time.Millisecond,
        })
        if err.Error() == notQuiescedMsg {
                s.Log(notQuiescedMsg)
                err = nil
        }
        return tab, err
}

I was trying to compare err with notQuiescedError but apparently I cannot do that: one is an "error" and the other is a *E.  I tried casting the *E into error but that was not possible.

Uh I don't know why I could not make the comparison earlier.  Now this code works:

func addTabFromList(ctx context.Context, s *testing.State,
        cr *chrome.Chrome, quiescenceCode string) (*renderer, error) {
        tab, err := addTab(ctx, s, cr, nextURL())
        if err != nil {
                return nil, err
        }
        err = tab.conn.Exec(ctx, quiescenceCode)
        if err != nil {
                return nil, errors.Wrap(err, "cannot inject quiescence code")
        }
        notQuiescedMsg := "tab did not quiesce within timeout"
        notQuiescedError := errors.New(notQuiescedMsg)
        err = testing.Poll(ctx, func(ctx context.Context) error {
                done := false
                err := evalPromiseBody(ctx, s, tab.conn,
                        "resolve(window.__telemetry_testHasReachedNetworkQuiescence())", &done)
                if err != nil {
                        return err
                }
                if !done {
                        return notQuiescedError
                }
                return nil
        }, &testing.PollOptions{
                Timeout:  15 * time.Second,
                Interval: 100 * time.Millisecond,
        })
        if err == notQuiescedError {
                s.Log(notQuiescedMsg)
                err = nil
        }
        return tab, err
}
In any case this looks like a compiler or run-time library error.
Sorry, the code in #2 is wrong, because unfortunately testing.Poll wraps the notQuiescedError, so the comparison always fails.

I tried returning the error in a variable like this:

pollError := errors.New(notQuiescedMsg)
...
inside the poll function:
    if err != nil {
        pollError = err
        return err
    }

and then outside testing.Poll, check if pollError is no longer notQuiescedError.  But the assignment pollError = err fails:

./platform/tast-tests/src/chromiumos/tast/local/bundles/cros/platform/memory_pressure.go:187:14: cannot use err (type error) as type *"chromiumos/tast/errors".E in assignment: need type assertion

Full code:

       notQuiescedMsg := "tab did not quiesce within timeout"
        notQuiescedError := errors.New(notQuiescedMsg)
        pollError := notQuiescedError
        err = testing.Poll(ctx, func(ctx context.Context) error {
                done := false
                err := evalPromiseBody(ctx, s, tab.conn,
                        "resolve(window.__telemetry_testHasReachedNetworkQuiescence())", &done)
                if err != nil {
                        pollError = err
                        return err
                }
                if !done {
                        return notQuiescedError
                }
                return nil
        }, &testing.PollOptions{
                Timeout:  15 * time.Second,
                Interval: 100 * time.Millisecond,
        })
        if pollError == notQuiescedError {
                s.Log(notQuiescedMsg)
                err = nil
        }
        return tab, err
}

Oh wait, it works with

                        pollError = err.(*errors.E)

Interesting.

You're mixing error and *errors.E, which is often tricky. In the code in #c4, notQuiescedError and pollError have type *errors.E, but they should be error. Could you try:

 var notQuiescedError error = errors.New(notQuiescedMsg)

So forget about comments #2 and #4, they really have nothing to do with this bug.  The run-time error should not happen in any case.

Since it's a Go bug, not one of ours, I'll figure out where to report it instead, then close this.
Status: WontFix (was: Untriaged)
:/ I lost the ability to reproduce this quickly.
I don't think that this is a Go bug. It's perfectly normal for Go to panic at runtime when code tries to dereference a nil pointer (and Tast handled this as expected by recovering from the panic and just reporting the test as failing).

Sign in to add a comment