Thread sanitizer for Kotlin Coroutines?


#1

hello,

I would like to ask whether there is some thread sanitizer for for Kotlin’s coroutines as for Go, see race detector. Go’s race detector is a C++ program written in some internal Google project. They tried to make it work for Java as well, but this was unhappily discontinued, see topic detection of race conditions.

It would be very useful if there were something similar for coroutines in Kotlin. AFAIK, there isn’t. But is there a plan to have something like this? It is unclear to me whether it is feasible at all, because I don’t understand the problem domain well enough. But I’d be curious to hear whether there are any plans in that way.

Regads, Oliver


#2

Could you explain, what it should do? Java/Kotlin contrary to C/C++ (don’t know about Go) is designed as a multithread language, so there are tools like locks and thread control build inside the language. I don’t see any reason to use external tool. As for coroutines, they are designed to avoid data races if used properly. The only scenario, where it fails is when you try to write some kind of external data from inside the coroutine (which you should obviously avoid). Even in this case, you can always use mutex lock or even thread safe collection for that.


#3

Go’s race detector detects race conditions at runtime when testing. I’m sure Roman Elizarov knows what it is about. You can read the description in the provided link.


#4

Heh, if only. It took java until 1.4 to handle concurrency with anything approaching sanity, and even then the level of usefulness isn’t great. Go, being a language that’s 20 years newer, is head and shoulders better than java at concurrent systems. How you parallelize that can still be tricky.

There is of course good ol’ JC stress and a couple other java fuzz-testing libraries that attempt to do the same thing, but I’ve never had much luck with them.

I’d be interested to see some kind of testing system that uses different coroutine-job schedules to verify some level of code correctness while also letting you relatively easily get a kind of trace for debugging.