[quickjs-devel] GC possible bug

  • From: jordi domenech flores <jordi@xxxxxxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Mon, 2 Jan 2023 10:56:05 +0100

1st of all... Happy New Year!

We think we've found a bug. Just sharing with you just in case somebody
came across the same and found the root. This is the minimal repro example:

````
async function createTask () {
  return new Promise((resolve) => {
    Promise.resolve().then(function () {
      const buf = new Uint8Array(1000000)
      resolve(buf)
    })
  })
}

run()

async function run () {
  let fn = () => {}

  let done = () => {
    fn()
  }

  createTask().then(done)

  const p = new Promise(() => {})

  console.log('pre await')
  await p
  console.log('post done')
}
````

If you run the gist with (e.g. CONFIG_ASAN) you notice the `fn` function is
GC'd as soon as the big UInt8Array is created, and so the `createTask`
promise resolution crashes. If we move the array creation outside
`Promise.resolve().then` this is not happening.

Let's see if we can solve this! Thanks for reading :)

Other related posts:

  • » [quickjs-devel] GC possible bug - jordi domenech flores