-
Notifications
You must be signed in to change notification settings - Fork 529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add util method to check that StackOverflowError is reproducible #1923
add util method to check that StackOverflowError is reproducible #1923
Conversation
…stack depth to reproduce SOE for 2 other stack-safety tests
Thanks for opening this PR. I'm honestly against this change, firstly because Second, it seems that Scala.js does not like this change at all, probably for similar reasons, and this even happens with quickly optimized code, which is in general better at recognizing and recovering from exceptions. Fully optimized Scala.js might have even bigger stability issues. The following excerpt is taken directly from the /**
* Extractor of non-fatal Throwables. Will not match fatal errors like `VirtualMachineError`
* (for example, `OutOfMemoryError` and `StackOverflowError`, subclasses of `VirtualMachineError`), `ThreadDeath`,
* `LinkageError`, `InterruptedException`, `ControlThrowable`.
*/ with the code being the following: object NonFatal {
/**
* Returns true if the provided `Throwable` is to be considered non-fatal, or false if it is to be considered fatal
*/
def apply(t: Throwable): Boolean = t match {
// VirtualMachineError includes OutOfMemoryError and other fatal errors
case _: VirtualMachineError | _: ThreadDeath | _: InterruptedException | _: LinkageError | _: ControlThrowable => false
case _ => true
}
/**
* Returns Some(t) if NonFatal(t) == true, otherwise None
*/
def unapply(t: Throwable): Option[Throwable] = if (apply(t)) Some(t) else None
} |
@vasilmkd thanks for the prompt response, really appreciate it :) as well as honest feedback. To me personally there's an open question if this PR is not merged, how can we be sure that stack-safety tests are actually working and would fail if stack-safety is broken? Please don't get me wrong, I'm not trying to insist on merging this PR :) Edit: found a suggestion to read https://pangin.pro/posts/stack-overflow-handling ( reading now :) ) |
I read the JEP, and while I really appreciate the effort, it has 2 "problems" that are IMO deal breakers for Cats Effect. The JEP is explicitly said to not work on Windows, which is a platform we officially support and explicitly test on. The second is that this JEP arrived in Java 9, and we absolutely must support Java 8. Again, I'm not saying that this is not a good effort, far from it. However, I still feel uncomfortable including this in our build pipeline and potentially destabilizing the build by making assumptions on undocumented behavior. With that being said, if other contributors do not share my opinions, I will not oppose this addition. 😄 |
@vasilmkd Totally understand and respect your decision :) What do you think about bumping the depth to I was also asking the same question in telegram channel (sorry it's a Russian speaking one), and got some explanations from Aleksey Shipelev there (https://shipilev.net), and IIUC it should not break the JVM. |
That's awesome! So if I understand correctly, the worst thing that can happen is that the thread will just die? |
@vasilmkd If I understand correctly - yes it's the worst thing that can happen in such case, but I'm not an expert in JVM, Also I updated my previous comment too late (after your response, sorry about that), so I would repeat that small question again :) What do you think about bumping the depth to 50000 in some tests (instead of current 10000) Edit here are some proofs that 10000 was not enough for both JS and JVM envs
|
About JEP 270 - I didn't mean that it's making this PR safer in any way (sorry for any confusion), it was my first closest finding on the topic, so we don't need it for this PR, as a result Java 9 and Windows support are not relevant. |
I actually really like the idea here. I need to study it a bit more but, given that it's in tests, it doesn't seem horrible. SOE definitely doesn't leave the JVM in an undefined state (unlike OOM), so it's not totally corrupting things. |
I think the best you can do on Scala.js is check the error message and I couldn't figure out if it's even possible on Scala Native. |
Some JavaScript runtimes have automatic tailcall elimination in certain common circumstances, likely including this one. As an example, I've had difficulty getting V8 to stackoverflow without significantly obfuscating the recursion. It usually just runs out of memory instead. |
@nikitapecasa sorry for the delay on this issue. I think there is merit to this change, and in order to get the most of it while avoiding unnecessary complexity to trick node/Scala.js, let's just make this test platform specific for the JVM only. |
So 50000 isn't enough? I'm confused. |
This is ready for merging. |
@vasilmkd well done! I really like how you changed the method to actually reach SOE instead of trying to guess it :) I have a few questions though
|
The laws need to work on Scala.js. Personally, I think it's fine to leave them as is. I'll let other maintainers decide. |
Thank you for chasing this! |
This can be useful to make sure that stack-safety tests are actually reproducing SOE with corresponding stack depth.
If you like the idea, I can add the same check for IOspec