guild icon
Toit
#What is Primitive: 18:1 in 2.0.0-alpha.180?
Thread channel in help
addshore
addshore 05/19/2025 09:11 AM
Got a stack and would love to know what primitive this is in this version?
Perhaps I should write down how to find this out as it seems to come up a fair bit.

Potential deadlock detected: Process: 3 Program: a4ae897d-01f6-7c9d-fc35-fbe22fd3660d BCI: 0x3365 Primitive: 18:1 fatal: Potential dead-lock
floitsch
floitsch 05/19/2025 09:12 AM
looking
floitsch
floitsch 05/19/2025 09:13 AM
Program your microcontrollers in a fast and robust high-level language. - toitlang/toit
floitsch
floitsch 05/19/2025 09:14 AM
Weird... I have never seen a timeout there.
addshore
addshore 05/19/2025 09:14 AM
interesting
floitsch
floitsch 05/19/2025 09:15 AM
update_resource_monitor starts with Locker locker(mutex_) so this could actually be a real deadlock.
floitsch
floitsch 05/19/2025 09:15 AM
How often does it hapen?
floitsch
floitsch 05/19/2025 09:15 AM
Any idea what could be causing it?
addshore
addshore 05/19/2025 09:16 AM
Not sure, but got it reported from a client, I myself havn't seen it.
addshore
addshore 05/19/2025 09:17 AM
The code makes use of Latches and Channels
addshore
addshore 05/19/2025 09:17 AM
Channels working as message inboxes / queues for processing
Latches working as things to wait for responses to messages that are potentially being sent
addshore
addshore 05/19/2025 09:17 AM
The channels are rather high throughput
floitsch
floitsch 05/19/2025 09:18 AM
Still weird. But will discuss it with Kasper in our daily later today.
馃憤1
addshore
addshore 05/19/2025 09:19 AM
A Toit package for working with Lightbug devices in Toit - lightbug-io/toit-lightbug
floitsch
floitsch 05/19/2025 09:19 AM
(side-note: kebab-case!!! :馃檪:
馃憖1
addshore
addshore 05/19/2025 09:20 AM
:馃槢:
addshore
addshore 05/19/2025 09:21 AM
The other non public codes does also...

channel_ = Channel 20 .... channel-send msg/protocol.Message -> none: if active_: channel_.send msg ... run: while true: while msg / protocol.Message? := channel_.receive --blocking=false: ...

and also have a location-channel / Channel := ? that is never used
floitsch
floitsch 05/19/2025 09:29 AM
I think the register-monitor-notifier is only used when a new object (that can have system events) is created, or when sleep is called. During a receive call that should have already been done.
bitphlipphar
bitphlipphar 05/19/2025 10:23 AM
@addshore Do you think we can get our hands on the snapshot for the program where this fails? a4ae897d-01f6-7c9d-fc35-fbe22fd3660d is the id of it, so maybe we can get the snapshot from the envelope.
addshore
addshore 05/19/2025 11:42 AM
@bitphlipphar I expect so, I'll go and figure that out :馃檪:
addshore
addshore 05/19/2025 11:43 AM
Just the toit files won't be enough right?
addshoreOPaddshore
Just the toit files won't be enough right?
floitsch
floitsch 05/19/2025 12:21 PM
The toit files might be enough, if we compile to the same snapshot, but the actual snapshot would be more convenient.
If you compiled the pod on your machine you can try to find it in $HOME/local/.state/toit/a4ae897d-01f6-7c9d-fc35-fbe22fd3660d.snapshot
addshore
addshore 05/19/2025 12:21 PM
aaah lovely! that might be the pointer I needed!
addshore
addshore 05/19/2025 12:23 PM
I'll send that over to the person that was running it to see if they can get the snapshot to me
馃憤1
floitsch
floitsch 05/19/2025 12:27 PM
The snapshot is also in the pod. So if it's not in the state directory, then you can download the pod and extract it from there.
馃憤1
addshore
addshore 05/20/2025 10:48 AM
Also, does it mke sense for me to plop this one on github too to track it there?
floitsch
floitsch 05/20/2025 10:49 AM
Good question. Probably yes. Currently it doesn't look like a 5-minute fix.
馃憤1
addshore
addshore 05/20/2025 10:49 AM
Ill go write it now and summarize what is here so far
馃檹1
addshore
addshore 05/20/2025 10:52 AM
Reported in a thread at https://discord.com/channels/918498540232253480/1373951179188342874 @floitsch mentioned Events::register_monitor_notifier toit/src/primitive.h Line 567 in c44b5ed PRIMITIVE(...
bitphlipphar
bitphlipphar 05/21/2025 11:25 AM
Unsurprisingly the snapshot shows that the bytecode that we're stuck in for too long is the invoke primitive bytecode (0x3365 = 13157):

13149: register-monitor-notifier_ <sdk>/core/events_.toit:73:1 0/13153 [018] - load local 4 1/13154 [048] - as class RpcRequestQueue_?(125 - 136) 3/13156 [041] - pop 1 4/13157 [089] - invoke primitive {events::register_monitor_notifier} 8/13161 [053] - invoke static throw <sdk>/core/exceptions.toit:39:1 11/13164 [041] - pop 1
馃憖1
30 messages in total