Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPD when calling deferred handle.Dispose #4279

Open
ankur22 opened this issue Jan 24, 2025 · 0 comments
Open

NPD when calling deferred handle.Dispose #4279

ankur22 opened this issue Jan 24, 2025 · 0 comments
Labels

Comments

@ankur22
Copy link
Contributor

ankur22 commented Jan 24, 2025

Brief summary

Here's the stack trace:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x13957a1]

goroutine 1517439 [running]:
go.k6.io/k6/js/modules/k6/browser/common.(*Frame).waitForSelector.func1()
go.k6.io/k6/js/modules/k6/browser/common/frame.go:505 +0x21
go.k6.io/k6/js/modules/k6/browser/common.(*Frame).waitForSelector(0xc004638fc0, {0xc00041e2d0, 0x2a}, 0xc00005d3e0)
go.k6.io/k6/js/modules/k6/browser/common/frame.go:511 +0x434
go.k6.io/k6/js/modules/k6/browser/common.(*Frame).typ.(*Frame).newAction.func2({0x1f9f158, 0xc001bee770}, 0xc004f21340, 0xc004f21c70)
go.k6.io/k6/js/modules/k6/browser/common/frame.go:2111 +0xfb
created by go.k6.io/k6/js/modules/k6/browser/common.call in goroutine 1517438
go.k6.io/k6/js/modules/k6/browser/common/helpers.go:104 +0x14c

Looking at the code in question:

		defer func() {
			if err := handle.Dispose(); err != nil {
				err = fmt.Errorf("disposing element handle: %w", err)
				rerr = errors.Join(err, rerr)
			}
		}()
		if handle, err = ec.adoptElementHandle(handle); err != nil {
			return nil, fmt.Errorf("waiting for selector %q: adopting element handle: %w", selector, err)
		}

If an error is returned from ec.adoptElementHandle it overwrites the handle with a nil. The deferred function tries to use the handle but fails with an NPD since it is now nil.

k6 version

v0.56.0

OS

na

Docker version and image (if applicable)

No response

Steps to reproduce the problem

NA

Expected behaviour

Don't NPD

Actual behaviour

NPD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant