You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The cause of this NPD is due to the browser module not correctly checking the arguments before trying to work with them. With JSHandle.evaluate the pageFunc argument is required, but the browser module doesn't correctly check whether it is null/undefined before working with it.
There are many other examples within the browser module where it doesn't first validate the argument before working with it (page, frame, elementHandle).
This issue can be replicated with:
import{browser}from'k6/browser';exportconstoptions={scenarios: {ui: {executor: 'shared-iterations',options: {browser: {type: 'chromium',},},},},}exportdefaultasyncfunction(){constpage=awaitbrowser.newPage();try{awaitpage.goto('https://test.k6.io/my_messages.php');constjsHandle=awaitpage.waitForSelector('input[name="login"]');// This is incorrect, the pageFunction arg is required on evaluate and this is// why we get a NPD since we don't check it is nil first.awaitjsHandle.evaluate();}finally{awaitpage.close();}}
There's also an issue with waitForSelector -- it returns an ElementHandle, but it is mapped to a JSHandle 🤔
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x1606eea]
goroutine 1536 [running]:
github.com/grafana/xk6-browser/browser.mapJSHandle.func3.1()
github.com/grafana/[email protected]/browser/js_handle_mapping.go:27 +0x16a
github.com/grafana/xk6-browser/k6ext.promise.func1()
github.com/grafana/[email protected]/k6ext/promise.go:24 +0x2c
created by github.com/grafana/xk6-browser/k6ext.promise in goroutine 53
github.com/grafana/[email protected]/k6ext/promise.go:23 +0x9a
test run: 3526237
xk6-browser version
v1.9.1
The content you are editing has changed. Please copy your edits and refresh the page.
ankur22
changed the title
mapJSHandle invalid memory address or nil pointer dereference
Evaluate and evaluateHandle cause NPD on nil pageFunc
Nov 21, 2024
Brief summary
The cause of this NPD is due to the browser module not correctly checking the arguments before trying to work with them. With
JSHandle.evaluate
thepageFunc
argument is required, but the browser module doesn't correctly check whether it isnull
/undefined
before working with it.There are many other examples within the browser module where it doesn't first validate the argument before working with it (page, frame, elementHandle).
This issue can be replicated with:
There's also an issue with
waitForSelector
-- it returns anElementHandle
, but it is mapped to aJSHandle
🤔test run: 3526237
xk6-browser version
v1.9.1
Tasks
mapJSHandle
invalid memory address or nil pointer dereference #1544The text was updated successfully, but these errors were encountered: