rubyjs / therubyracer

Embed the V8 Javascript Interpreter into Ruby
1.66k stars 193 forks source link

Deferred callstack extraction can lead to very dangerous concurrency bugs #290

Closed SamSaffron closed 10 months ago

SamSaffron commented 10 years ago

I was debugging a hard deadlock in Discourse today and found the V8::Error aquires a lock when its extracting backtraces from the vm.

This can lead to all sorts of very had to debug issues.

To work around I put this in place

https://github.com/discourse/discourse/commit/1556548ff6633cbfac8f463a82628f45afb24856

However, I feel that the ruby racer should simply calculate the backtrace at the point in time that the vm chokes and then it will not need to get access to the vm.

cowboyd commented 10 years ago

Ideally yes, it would be nice to capture the exception at the point it occurred. This can be very hard to do in practice though especially since you can have several JavaScript call stacks from different contexts embedded within each other. Currently, we will report them all.

I recall trying to collect this information at the site of the exception, and having a rough time of it. The current implementation was definitely a "phew, got something working." solution.