yield_local can cause stack overflow
Author: Pr0metheanCreated Jun 25, 2023Updated Jul 16, 2026
When a job calls yield_local, Rayon loads another job onto the stack on top of it. If lots of jobs are calling it, this can cause a stack overflow.
To fix this, Rayon should give each thread a flag that tracks whether yield_local is already on the stack. If it is and is called again, yield_local should return immediately. (There may need to be a third value in the Yield enum for this case.) Alternately, it could check available stack space.
Example stack trace: stack_trace.txt
Source: rayon-rs/rayon