sqlite: throw within aggregate's `result` callback causes segfault

Version

v24.0.2

Platform

Linux 6.11.0-25-generic (Ubuntu 24.04) x86_64

Subsystem

sqlite

What steps will reproduce the bug?

const sqlite = require('node:sqlite')
const db = new sqlite.DatabaseSync(':memory:')

db.exec('CREATE TABLE test (value INTEGER)')

db.aggregate('result_throws', {
  start: null,
  step: v => v,
  result: () => { throw new Error() },
})

db.prepare('SELECT result_throws() FROM test').get()
// Segmentation fault

How often does it reproduce? Is there a required condition?

What is the expected behavior? Why is that the expected behavior?

The aggregate handler should abort gracefully.

What do you see instead?

An offended kernel.

Additional information

No response