Lodestone-Team / lodestone_core

The backend for Lodestone, A free, open source server hosting tool for Minecraft and other multiplayers
https://www.lodestone.cc/
GNU Affero General Public License v3.0
60 stars 6 forks source link

Random seg fault when canceling a tokio handle running a JS event loop #77

Closed CheatCod closed 1 year ago

CheatCod commented 1 year ago

Intention:

Lodestone should not seg fault under any circumstances.

Why is it necessary:

Seg fault is bad and is indicative of memory access violation/corruption.

While I can't consistently reproduce this issue, the rough steps seem to be:

  1. spawn multiple JS runtime within one macro executor, let $n$ be the number of js runtimes
  2. cancel some runtime $a$ where $a < n - 1$, then cancel runtime $n-1$ and $n$
  3. Seg faults occur in debug mode (not tested in release)
CheatCod commented 1 year ago

Solved with a thread-safe handle