-
Type: Bug
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
Goals
No segfault when closing Realm in the Results#addListener callback.
Expected Results
Either a clean error being thrown that I cannot close the realm in the callback or even better that it would just close in a clean way, as if it was closed outside of the callback.
Actual Results
PID 12063 received SIGSEGV for address: 0x20
0 segfault-handler.node 0x00000001027a5408 _ZL16segfault_handleriP9__siginfoPv + 312
1 libsystem_platform.dylib 0x00007fff78bf6f5a _sigtramp + 26
2 ??? 0x0000000000000000 0x0 + 0
3 realm.node 0x00000001048cf161 _ZN5realm5_impl16RealmCoordinator16promote_to_writeERNS_5RealmE + 141
4 realm.node 0x00000001048b3fc0 _ZN5realm5Realm17begin_transactionEv + 180
5 realm.node 0x000000010486ee88 _ZN5realm2js10RealmClassINS_4node5TypesEE5writeEPN2v87IsolateENS5_5LocalINS5_6ObjectEEERNS0_9ArgumentsIS3_EERNS0_11ReturnValueIS3_EE + 158
6 realm.node 0x0000000104868e21 _ZN5realm2js4wrapIXadL_ZNS0_10RealmClassINS_4node5TypesEE5writeEPN2v87IsolateENS6_5LocalINS6_6ObjectEEERNS0_9ArgumentsIS4_EERNS0_11ReturnValueIS4_EEEEEEvRKN3Nan20FunctionCallbackInfoINS6_5ValueEEE + 238
7 realm.node 0x000000010481348e _ZN3Nan3impL23FunctionCallbackWrapperERKN2v820FunctionCallbackInfoINS1_5ValueEEE + 136
8 node 0x00000001001fa832 _ZN2v88internal25FunctionCallbackArguments4CallEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEE + 466
9 node 0x000000010025af90 _ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEESA_NS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EENS0_16BuiltinArgumentsE + 816
10 node 0x000000010025a5d0 _ZN2v88internalL26Builtin_Impl_HandleApiCallENS0_16BuiltinArgumentsEPNS0_7IsolateE + 288
11 ??? 0x0000090e456042fd 0x0 + 9956898128637
12 ??? 0x0000090e456bd196 0x0 + 9956898886038
Segmentation fault: 11
Steps to Reproduce
- Open a Realm
- Register a listener to a class of objects, which calls realm.close() from the callback.
- Add an object to the Realm to trigger the callback.
Code Sample
npm install realm segfault-handler
const Realm = require('realm'); const SegfaultHandler = require('segfault-handler'); SegfaultHandler.registerHandler('crash.log'); // Delete any previous default.realm Realm.deleteFile({ }); async function test() { const realm = new Realm({ schema: [{ name: 'Clazz', properties: {} }] }); const objects = realm.objects('Clazz'); await new Promise(resolve => { objects.addListener((collection, changes) => { console.log(`Realm now contains ${collection.length} objects`); realm.close(); resolve(); }); // Create an object realm.write(() => { realm.create('Clazz', {}); }); }); } async function run() { for (let i = 0; i < 10; i++) { console.log(`Attempt #${i}`); await test(); } } run().then(() => { process.exit(0); }, err => { console.error(err); process.exit(1); });
Version of Realm and Tooling
- Realm JS SDK Version: 2.22.0
- Node or React Native: Node
- Client OS & Version: MacOS 17.7
- Which debugger for React Native: N/A