Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm] GC of the callback delegate - Assertion at mono/metadata/class-init.c:2745 #55735

Closed
pavelsavara opened this issue Jul 15, 2021 · 4 comments · Fixed by #56538
Closed
Assignees
Milestone

Comments

@pavelsavara
Copy link
Member

pavelsavara commented Jul 15, 2021

Running
dnet build /p:TargetOS=Browser /p:TargetArchitecture=wasm /p:Configuration=Release /t:Test src\libraries\System.Private.Runtime.InteropServices.JavaScript\tests /p:WithCategories="Pavel"

on this change main...pavelsavara:wasm_js_delegate

It's release build on windows V8.
The assert is in mono_class_init_internal (MonoClass *klass)

Security context: 0x037c08210491 <JSObject>#0#
 0: builtin exit frame: trace(this=0x037c08205ac9 <console map = 0000037C08242911>#1#,0x037c08205ac9 <console map = 0000037C08242911>#1#,0x037c0830dba1 <String[103]: c"* Assertion at C:/Dev/runtime/src/mono/mono/metadata/class-init.c:2745, condition `<disabled>' not met\n">)
 1: 555802 [0000037C084111CD] [dotnet.js:1] [bytecode=0000037C0868DC09 offset=113](this=0x037c08203201 <JSGlobal Object>#2#,17067,51903976,4,0,0)
 2: _emscripten_asm_const_int [0000037C08236CED] [dotnet.js:1] [bytecode=0000037C0868D98D offset=27](this=0x037c08203201 <JSGlobal Object>#2#,555802,5842024,5842000)
 3: WasmToJsFrame [pc: 000002BB1B1F6BB5]
 4: WASM [wasm://wasm/008b5212], function #8611 (''), pc=000002BB1B58AFA9 (+0x89), pos=1755692 (+77)
 5: WASM [wasm://wasm/008b5212], function #8436 (''), pc=000002BB1B6301D0 (+0x90), pos=1738855 (+32)
 6: WASM [wasm://wasm/008b5212], function #5029 (''), pc=000002BB1B78E942 (+0xe2), pos=1083280 (+102)
 7: WASM [wasm://wasm/008b5212], function #610 (''), pc=000002BB1B7504A7 (+0x47), pos=83275 (+31)
 8: WASM [wasm://wasm/008b5212], function #207 (''), pc=000002BB1B855B85 (+0x45), pos=28809 (+39)
 9: WASM [wasm://wasm/008b5212], function #98 (''), pc=000002BB1B921322 (+0x22), pos=19888 (+9)
10: WASM [wasm://wasm/008b5212], function #183 (''), pc=000002BB1B86AC52 (+0x52), pos=26400 (+1136)
11: WASM [wasm://wasm/008b5212], function #183 (''), pc=000002BB1B86AE29 (+0x229), pos=25536 (+272)
12: WASM [wasm://wasm/008b5212], function #3055 (''), pc=000002BB1B77E888 (+0x68), pos=639709 (+74)
13: WASM [wasm://wasm/008b5212], function #313 (''), pc=000002BB1B832DF1 (+0x151), pos=41518 (+140)
14: WASM [wasm://wasm/008b5212], function #1934 (''), pc=000002BB1B5762C1 (+0x101), pos=317207 (+113)
15: WASM [wasm://wasm/008b5212], function #5716 (''), pc=000002BB1B7E2F6C (+0x8c), pos=1289316 (+52)
16: WASM [wasm://wasm/008b5212], function #2145 (''), pc=000002BB1B710232 (+0xf232), pos=422861 (+52208)
17: WASM [wasm://wasm/008b5212], function #6610 (''), pc=000002BB1B6ECA85 (+0x1a5), pos=1465612 (+208)
18: WASM [wasm://wasm/008b5212], function #8304 (''), pc=000002BB1B66363E (+0xede), pos=1702089 (+43)
19: WASM [wasm://wasm/008b5212], function #3472 (''), pc=000002BB1B9255FA (+0x19a), pos=729709 (+106)
20: WASM [wasm://wasm/008b5212], function #686 (''), pc=000002BB1B74F75C (+0x9c), pos=91144 (+36)
21: WASM [wasm://wasm/008b5212], function #8464 (''), pc=000002BB1B5FC6D6 (+0xf6), pos=1741953 (+95)
22: JsToWasmFrame [pc: 0000037C00209C1B]
23: call_method [0000037C0840F939] [dotnet.js:~1] [pc=0000037C002141F5](this=0x037c084086b1 <Object map = 0000037C08255881>#3#,51811048,25177376,0x037c08449285 <String[1]: "o">,0x037c0830d149 <Arguments map = 0000037C08243F19>#4#)
24: invoke_delegate [0000037C0840FA19] [dotnet.js:1] [bytecode=0000037C0847BA35 offset=182](this=0x037c084086b1 <Object map = 0000037C08255881>#3#,0x037c0840b3b1 <Object map = 0000037C081C27A9>#5#,0x037c0830d149 <Arguments map = 0000037C08243F19>#4#)
25: /* anonymous */ [0000037C0840BD51] [dotnet.js:1] [bytecode=0000037C0847B81D offset=14](this=0x037c083d6e09 <EventTarget map = 0000037C081C2439>#6#)
26: dispatchEvent [0000037C08479639] [0x037c080423b5 <undefined>:~29] [pc=0000037C0021D337](this=0x037c083d6e09 <EventTarget map = 0000037C081C2439>#6#,0x037c0830c9a9 <Object map = 0000037C081C25C9>#7#)
27: _mono_wasm_invoke_js_with_args [0000037C082374D5] [dotnet.js:~1] [pc=0000037C002129A7](this=0x037c08203201 <JSGlobal Object>#2#,4,43715728,29360096,44376528)
28: WasmToJsFrame [pc: 000002BB1B1F6585]
29: WASM [wasm://wasm/008b5212], function #2571 (''), pc=000002BB1B8CA626 (+0x4e6), pos=522492 (+414)
30: WASM [wasm://wasm/008b5212], function #2145 (''), pc=000002BB1B710079 (+0xf079), pos=374897 (+4244)
31: WASM [wasm://wasm/008b5212], function #6610 (''), pc=000002BB1B6ECA85 (+0x1a5), pos=1465612 (+208)
32: WASM [wasm://wasm/008b5212], function #8304 (''), pc=000002BB1B66363E (+0xede), pos=1702089 (+43)
33: WASM [wasm://wasm/008b5212], function #3472 (''), pc=000002BB1B9255FA (+0x19a), pos=729709 (+106)
34: WASM [wasm://wasm/008b5212], function #486 (''), pc=000002BB1B7FB25E (+0x3e), pos=70108 (+38)
35: WASM [wasm://wasm/008b5212], function #5899 (''), pc=000002BB1B81D5AC (+0x12cc), pos=1345744 (+2216)
36: WASM [wasm://wasm/008b5212], function #2571 (''), pc=000002BB1B8CA626 (+0x4e6), pos=522492 (+414)
37: WASM [wasm://wasm/008b5212], function #2145 (''), pc=000002BB1B710079 (+0xf079), pos=374897 (+4244)
38: WASM [wasm://wasm/008b5212], function #6610 (''), pc=000002BB1B6ECA85 (+0x1a5), pos=1465612 (+208)
39: WASM [wasm://wasm/008b5212], function #8304 (''), pc=000002BB1B66363E (+0xede), pos=1702089 (+43)
40: WASM [wasm://wasm/008b5212], function #3472 (''), pc=000002BB1B9255FA (+0x19a), pos=729709 (+106)
41: WASM [wasm://wasm/008b5212], function #686 (''), pc=000002BB1B74F75C (+0x9c), pos=91144 (+36)
42: WASM [wasm://wasm/008b5212], function #8464 (''), pc=000002BB1B5FC6D6 (+0xf6), pos=1741953 (+95)
43: JsToWasmFrame [pc: 0000037C000ED917]
44: invoke_method [0000037C0823E0C1] [dotnet.js:1] [bytecode=0000037C083E4E29 offset=39](this=0x037c084086b1 <Object map = 0000037C08255881>#3#)
45: _call_method_with_converted_args [0000037C0840F9D9] [dotnet.js:1] [bytecode=0000037C083E4B91 offset=55](this=0x037c084086b1 <Object map = 0000037C08255881>#3#,41980216,0,0x037c0846dbf9 <Object map = 0000037C082551A1>#8#,44287744,0x037c0804248d <true>,0x037c08042235 <null>)
46: call_method [0000037C0840F939] [dotnet.js:1] [bytecode=0000037C083E438D offset=202](this=0x037c084086b1 <Object map = 0000037C08255881>#3#,41980216,0,0x037c082125a5 <String[1]: #m>,0x037c0844ce71 <JSArray[1]>#9#)
47: /* anonymous */ [0000037C0844CE81] [dotnet.js:1] [bytecode=0000037C083E23E1 offset=89](this=0x037c08203201 <JSGlobal Object>#2#)
48: call_assembly_entry_point [0000037C0840FAB9] [dotnet.js:1] [bytecode=0000037C083D9A35 offset=17](this=0x037c084086b1 <Object map = 0000037C08255881>#3#,0x037c08410fe5 <String[18]: "WasmTestRunner.dll">,0x037c0844cea1 <JSArray[1]>#10#,0x037c082125a5 <String[1]: #m>)
49: init [0000037C08410DFD] [runtime.js:356] [bytecode=0000037C083D9091 offset=677](this=0x037c08407f71 <Object map = 0000037C0824FD19>#11#)
50: loaded_cb [0000037C083C909D] [runtime.js:243] [bytecode=0000037C083D85D5 offset=90](this=0x037c08410e3d <Object map = 0000037C082512D1>#12#)
51: _finalize_startup [0000037C08419A95] [dotnet.js:1] [bytecode=0000037C083D6721 offset=409](this=0x037c08403399 <Object map = 0000037C081C2259>#13#,0x037c08410e3d <Object map = 0000037C082512D1>#12#,0x037c0841a1a5 <Object map = 0000037C08251871>#14#)
52: onPendingRequestComplete [0000037C08427D4D] [dotnet.js:1] [bytecode=0000037C083CB95D offset=45](this=0x037c08203201 <JSGlobal Object>#2#)
53: processFetchResponseBuffer [0000037C0841A225] [dotnet.js:1] [bytecode=0000037C083CB029 offset=84](this=0x037c08203201 <JSGlobal Object>#2#,0x037c084170d9 <Object map = 0000037C0824FBB1>#15#,0x037c084175d5 <String[21]: "dotnet.timezones.blat">,0x037c084399c5 <Uint8Array map = 0000037C082424D9>#16#)
54: StubFrame [pc: 0000037C0013F578]
55: StubFrame [pc: 0000037C000AA3FE]
56: EntryFrame [pc: 0000037C000878B7]
=====================
console.error: * Assertion at C:/Dev/runtime/src/mono/mono/metadata/class-init.c:2745, condition `<disabled>' not met
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Jul 15, 2021
@ghost
Copy link

ghost commented Jul 15, 2021

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Running
dnet build /p:TargetOS=Browser /p:TargetArchitecture=wasm /p:Configuration=Release /t:Test src\libraries\System.Private.Runtime.InteropServices.JavaScript\tests /p:WithCategories="Pavel"

on this change pavelsavara@f4a027f

It's release build on windows V8.

Security context: 0x037c08210491 <JSObject>#0#
 0: builtin exit frame: trace(this=0x037c08205ac9 <console map = 0000037C08242911>#1#,0x037c08205ac9 <console map = 0000037C08242911>#1#,0x037c0830dba1 <String[103]: c"* Assertion at C:/Dev/runtime/src/mono/mono/metadata/class-init.c:2745, condition `<disabled>' not met\n">)
 1: 555802 [0000037C084111CD] [dotnet.js:1] [bytecode=0000037C0868DC09 offset=113](this=0x037c08203201 <JSGlobal Object>#2#,17067,51903976,4,0,0)
 2: _emscripten_asm_const_int [0000037C08236CED] [dotnet.js:1] [bytecode=0000037C0868D98D offset=27](this=0x037c08203201 <JSGlobal Object>#2#,555802,5842024,5842000)
 3: WasmToJsFrame [pc: 000002BB1B1F6BB5]
 4: WASM [wasm://wasm/008b5212], function #8611 (''), pc=000002BB1B58AFA9 (+0x89), pos=1755692 (+77)
 5: WASM [wasm://wasm/008b5212], function #8436 (''), pc=000002BB1B6301D0 (+0x90), pos=1738855 (+32)
 6: WASM [wasm://wasm/008b5212], function #5029 (''), pc=000002BB1B78E942 (+0xe2), pos=1083280 (+102)
 7: WASM [wasm://wasm/008b5212], function #610 (''), pc=000002BB1B7504A7 (+0x47), pos=83275 (+31)
 8: WASM [wasm://wasm/008b5212], function #207 (''), pc=000002BB1B855B85 (+0x45), pos=28809 (+39)
 9: WASM [wasm://wasm/008b5212], function #98 (''), pc=000002BB1B921322 (+0x22), pos=19888 (+9)
10: WASM [wasm://wasm/008b5212], function #183 (''), pc=000002BB1B86AC52 (+0x52), pos=26400 (+1136)
11: WASM [wasm://wasm/008b5212], function #183 (''), pc=000002BB1B86AE29 (+0x229), pos=25536 (+272)
12: WASM [wasm://wasm/008b5212], function #3055 (''), pc=000002BB1B77E888 (+0x68), pos=639709 (+74)
13: WASM [wasm://wasm/008b5212], function #313 (''), pc=000002BB1B832DF1 (+0x151), pos=41518 (+140)
14: WASM [wasm://wasm/008b5212], function #1934 (''), pc=000002BB1B5762C1 (+0x101), pos=317207 (+113)
15: WASM [wasm://wasm/008b5212], function #5716 (''), pc=000002BB1B7E2F6C (+0x8c), pos=1289316 (+52)
16: WASM [wasm://wasm/008b5212], function #2145 (''), pc=000002BB1B710232 (+0xf232), pos=422861 (+52208)
17: WASM [wasm://wasm/008b5212], function #6610 (''), pc=000002BB1B6ECA85 (+0x1a5), pos=1465612 (+208)
18: WASM [wasm://wasm/008b5212], function #8304 (''), pc=000002BB1B66363E (+0xede), pos=1702089 (+43)
19: WASM [wasm://wasm/008b5212], function #3472 (''), pc=000002BB1B9255FA (+0x19a), pos=729709 (+106)
20: WASM [wasm://wasm/008b5212], function #686 (''), pc=000002BB1B74F75C (+0x9c), pos=91144 (+36)
21: WASM [wasm://wasm/008b5212], function #8464 (''), pc=000002BB1B5FC6D6 (+0xf6), pos=1741953 (+95)
22: JsToWasmFrame [pc: 0000037C00209C1B]
23: call_method [0000037C0840F939] [dotnet.js:~1] [pc=0000037C002141F5](this=0x037c084086b1 <Object map = 0000037C08255881>#3#,51811048,25177376,0x037c08449285 <String[1]: "o">,0x037c0830d149 <Arguments map = 0000037C08243F19>#4#)
24: invoke_delegate [0000037C0840FA19] [dotnet.js:1] [bytecode=0000037C0847BA35 offset=182](this=0x037c084086b1 <Object map = 0000037C08255881>#3#,0x037c0840b3b1 <Object map = 0000037C081C27A9>#5#,0x037c0830d149 <Arguments map = 0000037C08243F19>#4#)
25: /* anonymous */ [0000037C0840BD51] [dotnet.js:1] [bytecode=0000037C0847B81D offset=14](this=0x037c083d6e09 <EventTarget map = 0000037C081C2439>#6#)
26: dispatchEvent [0000037C08479639] [0x037c080423b5 <undefined>:~29] [pc=0000037C0021D337](this=0x037c083d6e09 <EventTarget map = 0000037C081C2439>#6#,0x037c0830c9a9 <Object map = 0000037C081C25C9>#7#)
27: _mono_wasm_invoke_js_with_args [0000037C082374D5] [dotnet.js:~1] [pc=0000037C002129A7](this=0x037c08203201 <JSGlobal Object>#2#,4,43715728,29360096,44376528)
28: WasmToJsFrame [pc: 000002BB1B1F6585]
29: WASM [wasm://wasm/008b5212], function #2571 (''), pc=000002BB1B8CA626 (+0x4e6), pos=522492 (+414)
30: WASM [wasm://wasm/008b5212], function #2145 (''), pc=000002BB1B710079 (+0xf079), pos=374897 (+4244)
31: WASM [wasm://wasm/008b5212], function #6610 (''), pc=000002BB1B6ECA85 (+0x1a5), pos=1465612 (+208)
32: WASM [wasm://wasm/008b5212], function #8304 (''), pc=000002BB1B66363E (+0xede), pos=1702089 (+43)
33: WASM [wasm://wasm/008b5212], function #3472 (''), pc=000002BB1B9255FA (+0x19a), pos=729709 (+106)
34: WASM [wasm://wasm/008b5212], function #486 (''), pc=000002BB1B7FB25E (+0x3e), pos=70108 (+38)
35: WASM [wasm://wasm/008b5212], function #5899 (''), pc=000002BB1B81D5AC (+0x12cc), pos=1345744 (+2216)
36: WASM [wasm://wasm/008b5212], function #2571 (''), pc=000002BB1B8CA626 (+0x4e6), pos=522492 (+414)
37: WASM [wasm://wasm/008b5212], function #2145 (''), pc=000002BB1B710079 (+0xf079), pos=374897 (+4244)
38: WASM [wasm://wasm/008b5212], function #6610 (''), pc=000002BB1B6ECA85 (+0x1a5), pos=1465612 (+208)
39: WASM [wasm://wasm/008b5212], function #8304 (''), pc=000002BB1B66363E (+0xede), pos=1702089 (+43)
40: WASM [wasm://wasm/008b5212], function #3472 (''), pc=000002BB1B9255FA (+0x19a), pos=729709 (+106)
41: WASM [wasm://wasm/008b5212], function #686 (''), pc=000002BB1B74F75C (+0x9c), pos=91144 (+36)
42: WASM [wasm://wasm/008b5212], function #8464 (''), pc=000002BB1B5FC6D6 (+0xf6), pos=1741953 (+95)
43: JsToWasmFrame [pc: 0000037C000ED917]
44: invoke_method [0000037C0823E0C1] [dotnet.js:1] [bytecode=0000037C083E4E29 offset=39](this=0x037c084086b1 <Object map = 0000037C08255881>#3#)
45: _call_method_with_converted_args [0000037C0840F9D9] [dotnet.js:1] [bytecode=0000037C083E4B91 offset=55](this=0x037c084086b1 <Object map = 0000037C08255881>#3#,41980216,0,0x037c0846dbf9 <Object map = 0000037C082551A1>#8#,44287744,0x037c0804248d <true>,0x037c08042235 <null>)
46: call_method [0000037C0840F939] [dotnet.js:1] [bytecode=0000037C083E438D offset=202](this=0x037c084086b1 <Object map = 0000037C08255881>#3#,41980216,0,0x037c082125a5 <String[1]: #m>,0x037c0844ce71 <JSArray[1]>#9#)
47: /* anonymous */ [0000037C0844CE81] [dotnet.js:1] [bytecode=0000037C083E23E1 offset=89](this=0x037c08203201 <JSGlobal Object>#2#)
48: call_assembly_entry_point [0000037C0840FAB9] [dotnet.js:1] [bytecode=0000037C083D9A35 offset=17](this=0x037c084086b1 <Object map = 0000037C08255881>#3#,0x037c08410fe5 <String[18]: "WasmTestRunner.dll">,0x037c0844cea1 <JSArray[1]>#10#,0x037c082125a5 <String[1]: #m>)
49: init [0000037C08410DFD] [runtime.js:356] [bytecode=0000037C083D9091 offset=677](this=0x037c08407f71 <Object map = 0000037C0824FD19>#11#)
50: loaded_cb [0000037C083C909D] [runtime.js:243] [bytecode=0000037C083D85D5 offset=90](this=0x037c08410e3d <Object map = 0000037C082512D1>#12#)
51: _finalize_startup [0000037C08419A95] [dotnet.js:1] [bytecode=0000037C083D6721 offset=409](this=0x037c08403399 <Object map = 0000037C081C2259>#13#,0x037c08410e3d <Object map = 0000037C082512D1>#12#,0x037c0841a1a5 <Object map = 0000037C08251871>#14#)
52: onPendingRequestComplete [0000037C08427D4D] [dotnet.js:1] [bytecode=0000037C083CB95D offset=45](this=0x037c08203201 <JSGlobal Object>#2#)
53: processFetchResponseBuffer [0000037C0841A225] [dotnet.js:1] [bytecode=0000037C083CB029 offset=84](this=0x037c08203201 <JSGlobal Object>#2#,0x037c084170d9 <Object map = 0000037C0824FBB1>#15#,0x037c084175d5 <String[21]: "dotnet.timezones.blat">,0x037c084399c5 <Uint8Array map = 0000037C082424D9>#16#)
54: StubFrame [pc: 0000037C0013F578]
55: StubFrame [pc: 0000037C000AA3FE]
56: EntryFrame [pc: 0000037C000878B7]
=====================
console.error: * Assertion at C:/Dev/runtime/src/mono/mono/metadata/class-init.c:2745, condition `<disabled>' not met
Author: pavelsavara
Assignees: -
Labels:

arch-wasm, area-System.Runtime.InteropServices.JavaScript

Milestone: -

@lambdageek
Copy link
Member

class-init.c:2745 is g_assert (klass) in mono_class_init_internal (MonoClass *klass). So uh... it would be really nice to have symbols for the calling stack frame ...

@pavelsavara
Copy link
Member Author

It's yet another GC issue, most likely. It is running many iterations of the code before it fails.
Unfortunately it doesn't reproduce on Debug build for me.

@lewing lewing removed the untriaged New issue has not been triaged by the area owner label Jul 15, 2021
@lewing lewing added this to the 6.0.0 milestone Jul 15, 2021
@pavelsavara
Copy link
Member Author

pavelsavara commented Jul 15, 2021

It's definitely GC of the delegate, but we are not aware of it on JS side. We re-create JSObject proxy for it in extract_mono_obj but it doesn't have the delagate on it anymore. And then we pass it to mono for that ugly failure above.

In my branch I added code to extract_mono_obj to fail faster with infamous Please check if it has been prematurely GC'd which was also reported to us on #55679

@pavelsavara pavelsavara changed the title [wasm] Assertion at mono/metadata/class-init.c:2745 [wasm] GC of the callback delegate - Assertion at mono/metadata/class-init.c:2745 Jul 26, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Aug 4, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 7, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Sep 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants