element-hq / element-web

A glossy Matrix collaboration client for the web.
https://element.io
GNU Affero General Public License v3.0
11.19k stars 2k forks source link

Scary "Uncaught Error: recursive use of an object detected which would lead to unsafe aliasing in rust" on startup #26864

Closed ara4n closed 8 months ago

ara4n commented 10 months ago

Steps to reproduce

  1. Upgraded EDR to 2024011101 (rust sdk 0.7.0 (746c5db)
  2. Migration of IndexeddbCryptoStore to v8 kicked off
  3. Immediately spat out some scary uncaught errors:
09:26:57.057 rageshake.ts:77 INFO matrix_sdk_indexeddb::crypto_store::migrations: IndexeddbCryptoStore upgrade data -> v8 starting
    at /home/runner/.cargo/git/checkouts/matrix-rust-sdk-1f4927f82a3d27bb/3e17fc2/crates/matrix-sdk-indexeddb/src/crypto_store/migrations.rs:316
09:27:01.036 rageshake.ts:77 INFO matrix_sdk_indexeddb::crypto_store::migrations: Fixing inbound group session data keys
    row_count=424319
    at /home/runner/.cargo/git/checkouts/matrix-rust-sdk-1f4927f82a3d27bb/3e17fc2/crates/matrix-sdk-indexeddb/src/crypto_store/migrations.rs:327
09:27:01.675 matrix_sdk_crypto_wasm.js:9107 Uncaught Error: recursive use of an object detected which would lead to unsafe aliasing in rust
    at module.exports.__wbindgen_throw (matrix_sdk_crypto_wasm.js:9107:1)
    at wasm_bindgen::throw_str::hdbe5c00d01779cd7 (015bc85e:0x3ddebc)
    at wasm_bindgen::__rt::borrow_fail::h04d5bedb4db8fb5d (015bc85e:0x3dded9)
    at byn$mgfn-shared$wasm_bindgen::__rt::WasmRefCell<T>::borrow_mut::h01c348272f2db5ab (015bc85e:0x3ef5c8)
    at wasm_bindgen::__rt::WasmRefCell<T>::borrow_mut::h01c348272f2db5ab (015bc85e:0x38153f)
    at <matrix_sdk_crypto_wasm::identifiers::UserId as wasm_bindgen::convert::traits::FromWasmAbi>::from_abi::h4888cd6fc5b4c5d8 (015bc85e:0x35d42b)
    at __wbg_userid_free (015bc85e:0x37dc9a)
    at matrix_sdk_crypto_wasm.js:1877:1
    at FinalizationRegistry.cleanupSome (<anonymous>)
09:27:01.676 matrix_sdk_crypto_wasm.js:9107 Uncaught Error: recursive use of an object detected which would lead to unsafe aliasing in rust
    at module.exports.__wbindgen_throw (matrix_sdk_crypto_wasm.js:9107:1)
    at wasm_bindgen::throw_str::hdbe5c00d01779cd7 (015bc85e:0x3ddebc)
    at wasm_bindgen::__rt::borrow_fail::h04d5bedb4db8fb5d (015bc85e:0x3dded9)
    at byn$mgfn-shared$wasm_bindgen::__rt::WasmRefCell<T>::borrow_mut::h01c348272f2db5ab (015bc85e:0x3ef5c8)
    at wasm_bindgen::__rt::WasmRefCell<T>::borrow_mut::h01c348272f2db5ab (015bc85e:0x38153f)
    at <matrix_sdk_crypto_wasm::identifiers::UserId as wasm_bindgen::convert::traits::FromWasmAbi>::from_abi::h4888cd6fc5b4c5d8 (015bc85e:0x35d42b)
    at __wbg_userid_free (015bc85e:0x37dc9a)
    at matrix_sdk_crypto_wasm.js:7298:1
    at FinalizationRegistry.cleanupSome (<anonymous>)

However, it then completed 5 minutes later:

09:32:25.095 rageshake.ts:77 INFO matrix_sdk_indexeddb::crypto_store::migrations: IndexeddbCryptoStore upgrade data -> v8 finished
    at /home/runner/.cargo/git/checkouts/matrix-rust-sdk-1f4927f82a3d27bb/3e17fc2/crates/matrix-sdk-indexeddb/src/crypto_store/migrations.rs:392
  1. The app then took minutes to send messages until I disabled backups (https://github.com/element-hq/element-web/issues/26783) - but then, more unusually, failed to decrypt messages too for about 5 minutes. It eventually unwedged though, and superficially seems to be working okay?

Outcome

What did you expect?

No scary uncaught errors during migrations which make it sound like rust has broken mid-migration.

Separately, If the app is going to spend 5 minutes doing a critical migration, it HAS to warn the user that it's upgrading itself, and for the user to be patient otherwise they'll just get bored and restart the app. Even I didn't realise the migration was still going (given the scary uncaught errors!) - have filed this at https://github.com/element-hq/element-web/issues/26864

What happened instead?

I thought the migration had failed. Perhaps it did? I don't know.

Operating system

No response

Application version

2024011101

How did you install the app?

No response

Homeserver

No response

Will you send logs?

Yes

ara4n commented 10 months ago

Looks like this may be unrelated to the migration, given I'm now getting the same two uncaught throws launching the app post-migration, and superficially the migration looks like it worked (the indexeddb says it's on version 8):

rageshake.ts:77 DEPRECATED CONFIG OPTION: In the future, default_server_name will not be accepted. Please use default_server_config instead.
consoleObj.<computed> @ rageshake.ts:77
10:05:06.388 rageshake.ts:77 getSessionLock[2751c9ba-c539-4355-a3d5-4ac71dc602a3] Last ping (from 3325501e-8c99-4ad8-b3b9-439b9928b2b2) was 66362ms ago: proceeding with startup
10:05:19.659 matrix_sdk_crypto_wasm.js:9107 Uncaught Error: recursive use of an object detected which would lead to unsafe aliasing in rust
    at module.exports.__wbindgen_throw (matrix_sdk_crypto_wasm.js:9107:1)
    at wasm_bindgen::throw_str::hdbe5c00d01779cd7 (015bc85e:0x3ddebc)
    at wasm_bindgen::__rt::borrow_fail::h04d5bedb4db8fb5d (015bc85e:0x3dded9)
    at byn$mgfn-shared$wasm_bindgen::__rt::WasmRefCell<T>::borrow_mut::h01c348272f2db5ab (015bc85e:0x3ef5c8)
    at wasm_bindgen::__rt::WasmRefCell<T>::borrow_mut::h01c348272f2db5ab (015bc85e:0x38153f)
    at <matrix_sdk_crypto_wasm::identifiers::UserId as wasm_bindgen::convert::traits::FromWasmAbi>::from_abi::h4888cd6fc5b4c5d8 (015bc85e:0x35d42b)
    at __wbg_userid_free (015bc85e:0x37dc9a)
    at matrix_sdk_crypto_wasm.js:7298:1
    at FinalizationRegistry.cleanupSome (<anonymous>)
module.exports.__wbindgen_throw @ matrix_sdk_crypto_wasm.js:9107
$wasm_bindgen::throw_str::hdbe5c00d01779cd7 @ 015bc85e:0x3ddebc
$wasm_bindgen::__rt::borrow_fail::h04d5bedb4db8fb5d @ 015bc85e:0x3dded9
$byn$mgfn-shared$wasm_bindgen::__rt::WasmRefCell<T>::borrow_mut::h01c348272f2db5ab @ 015bc85e:0x3ef5c8
$wasm_bindgen::__rt::WasmRefCell<T>::borrow_mut::h01c348272f2db5ab @ 015bc85e:0x38153f
$<matrix_sdk_crypto_wasm::identifiers::UserId as wasm_bindgen::convert::traits::FromWasmAbi>::from_abi::h4888cd6fc5b4c5d8 @ 015bc85e:0x35d42b
$__wbg_userid_free @ 015bc85e:0x37dc9a
(anonymous) @ matrix_sdk_crypto_wasm.js:7298
Show 2 more frames
Show less
10:05:19.660 matrix_sdk_crypto_wasm.js:9107 Uncaught Error: recursive use of an object detected which would lead to unsafe aliasing in rust
    at module.exports.__wbindgen_throw (matrix_sdk_crypto_wasm.js:9107:1)
    at wasm_bindgen::throw_str::hdbe5c00d01779cd7 (015bc85e:0x3ddebc)
    at wasm_bindgen::__rt::borrow_fail::h04d5bedb4db8fb5d (015bc85e:0x3dded9)
    at byn$mgfn-shared$wasm_bindgen::__rt::WasmRefCell<T>::borrow_mut::h01c348272f2db5ab (015bc85e:0x3ef5c8)
    at wasm_bindgen::__rt::WasmRefCell<T>::borrow_mut::h01c348272f2db5ab (015bc85e:0x38153f)
    at <matrix_sdk_crypto_wasm::identifiers::UserId as wasm_bindgen::convert::traits::FromWasmAbi>::from_abi::h4888cd6fc5b4c5d8 (015bc85e:0x35d42b)
    at __wbg_userid_free (015bc85e:0x37dc9a)
    at matrix_sdk_crypto_wasm.js:1877:1
    at FinalizationRegistry.cleanupSome (<anonymous>)
BillCarsonFr commented 8 months ago

Cannot reproduce, and not seen since the recent changes on database and migration. Closing for now, will re-open if new issue discovered.