News for hackers. Stuff that matters.
Re:Neat Rust Tricks: Passing Closures to C by a1369209993 on Monday November 25, 2019 @11:28PM (#21635641)
This fails horribly if called recursively (or from a signal handler). You need something like:

  wrapped_qsort(/* array,callback */)
    {
    auto tmp = CBQ;
    CBQ = wrap(callback);
    qsort(array.ptr,array.len,cbq_callback);
    CBQ = tmp; /* pop old value from stack */
    }
Re:Neat Rust Tricks: Passing Closures to C by richardwhiuk on Tuesday November 26, 2019 @05:25AM (#21637046)
It'll fail from a signal handler inside qsort, or inside the callback function.

It won't fail recursively - while the second call is happening, the first will be stored on the stack (see the take and replace in the callback shim function)