This is unsafe rightfully and should not be used without checking. It's just undefined behavior when using threads as it's not threadsafe. https://ttimo.typepad.com/blog/2024/11/the-steam-client-upda...
Tokio and Prctl = Nasty Bug
51–60 of 78 posts
Re: Tokio and Prctl = Nasty Bug
#52Seeing the first mention of 10 seconds, I thought (jokingly) - Why not grep the source for the 10 second value. Jokingly, because I thought it would be an emergent property, not a literal value. Turns out it was a literal value after all and grepping would have helped!
Re: Tokio and Prctl = Nasty Bug
#53Seeing the first mention of 10 seconds, I thought (jokingly) - Why not grep the source for the 10 second value. Jokingly, because I thought it would be an emergent property, not a literal value. Turns out it was a literal value after all and grepping would have helped!
There was no mention of a ten second interval anywhere in the code, only in the tests they wrote while debugging.
Re: Tokio and Prctl = Nasty Bug
#54I may be mistaken, but I believe the bug still exists, but in a more esoteric manner; and a future change might cause the bug to exist again. The author might want to warn against usage of `tokio::task::block_in_place`, if the underlying issue can't be fixed. The reason the current approach works is it runs on tokio's worker threads, which last the lifetime of the tokio runtime. However, if `tokio::task::block_in_pla…
My knowledge isn't very good here, but I assumed since they're using the single thread executor, everything was being spawned on the main thread. The only time new (temporary) threads were created was when calling `spawn_blocking`. And the main thread can't be moved because it's part of the `main()` call stack? Maybe...
Re: Tokio and Prctl = Nasty Bug
#55Earlier quoted context omitted.
It is sadly not propagated to grandchildren. I tries the subreaper approach, but it doesn't help. The children are reparented to the worker, but when the worker dies, they are then just reparented to init, like normally.
You also need to specifically have the subreaper process call the "wait" syscall, and wait for all children, otherwise of course they'll end up reparented to init. If you want to write a process manager, one of the process manager's responsibilities is waiting on its children.
Re: Tokio and Prctl = Nasty Bug
#56Earlier quoted context omitted.
I wonder if this is difference between libc fork (which calls clone syscall) and kernel fork syscall.
No, it isn’t. Neither glibc fork nor kernel fork syscall provide any special handling for PDEATHSIG beyond what clone syscall does.
(The article sets it after forking.)
Re: Tokio and Prctl = Nasty Bug
#57In a nutshell, if you want to use the death signal, which is very handy and useful, you also need to lock an OS thread so that it can't be destroyed. Fortunately I'm only spawning one process so I don't need to jump through hoops, I can just dedicate a thread to it, but it would be inconvenient to want to spawn lots of processes that way.
Speaking more generally, a lot of things that I learned in the 200xs apply to "processes", and things I just osmosed over the years as applying to "processes", were changed to apply to "threads" over the decades and a lot of people have not noticed that, even now. Even though I know this, my mental model of what is associated to a thread and what is associated to a process is quite weak, since I've not yet needed to acquire a deep understanding. In general I would suggest to people that if you are dealing with this sort of system programming that you at least keep this general idea in your head so that the thought pops up that if you're having trouble, it may be related to your internal beliefs that things related to "processes" are actually related to "threads" and in fact just because you did something like set a UID or something somewhere in your code doesn't necessarily mean that that UID will be in effect somewhere else.
Re: Tokio and Prctl = Nasty Bug
#58I have no clue about HyperQueue architecture, but is this really a problem? Normally if the main process of service exits then systemd will clean up the children. Why does HyperQueue need to implement it's own cleanup?
Re: Tokio and Prctl = Nasty Bug
#59Earlier quoted context omitted.
There's been no fundamental change in the kernel level representation of pthreads, they are still clone()d processes with just some sharing flags set differently that eg affect how PIDs work.
More precisely, distinguishing a process and a thread is a pointless overspecification. Unfortunately POSIX mandates it and glibc accepts it. If you want to register per-thread signal handlers you're forced to step outside the bounds of glibc and pthreads which I think is quite unfortunate.
Re: Tokio and Prctl = Nasty Bug
#60IORING_OP_CLONE and IORING_OP_EXEC have been proposed: https://lwn.net/Articles/1002371/