Fix potential race condition in multi-threaded assembly
This branch fixes a potential race condition and double free issue when using automatic differentiation and multi-threaded assembly.
This branch fixes a potential race condition and double free issue when using automatic differentiation and multi-threaded assembly.