--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Error
is a subclass of Throwable
that indicates serious problems that a reasonable application should not try to catch." - http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Error.html--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hey Victor
As you can see from my example those docs are not true (just like for StackOverflowError)
Talking about OutOfMemoryError specifically, it does not indicate that "Java Virtual Machine is broken or has run out of resources necessary for it to continue operating". In a lot of cases OOME just indicates a problem with a particular piece of code.
What harm would it cause if OOME was treated as NonFatal?
For more options, visit https://groups.google.com/groups/opt_out.
Do you have any sources regarding SOE?
I talked to multiple JVM vendors who said SOE was clean.
Cheers, V
--
You received this message because you are subscribed to a topic in the Google Groups "scala-language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scala-language/eC9dqTTBYHg/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to scala-languag...@googlegroups.com.
Personal experience with several JVMs. We wanted to file bugs, but when I spoke to JVM guys, they said even though they do their best to return cleanly, they can't guarantee it and won't fix it, since it is a permitted behaviour by the JVM spec.
As to SOE, in order to recover from it, one needs to work out the state of the stack in order to figure out where to return control. This is not always possible, when SOE occurs. Because monitor release happens in "finally", which is the catch (Throwable _), that is not guaranteed.JVM spec permits the VM to do undefined things if a Error is to be thrown. One of such strange permissions is GC being optional, by the way.
I'll see if I can find a reproducer.
}
catch( Throwable th )
{
System.out.println( "SOE in " + name + " @ level " + max + " caught @ " + n );
Hi Aleh,
email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
I guess OOME and SOE could leave vm in inconsistent state in some rare cases.
Obviously even Exception thrown from user code can potentially leave it in this state and we can't assume that it's safe to proceed..
But should we penalize every use case of scala.util.Try ?
What is the worst thing that could happen if Try (and other users of NonFatal) was catching OOME and SOE?
... and it is unsound to assume that we should abandon processing the request without a regular exception handling or kill the vm.
I've seen catching regular Exceptions leading to data corruption, but haven't ever seen someone terminating the vm because of SOE or OOME
Hi Victor
How would this benefit users of Try, Future and NonFatal?
Decrease data corruption chances by a factor so small that nor you nor twitter engineers considered to be greater than zero until this week?
Increase chances that scala users will see hanging Futures and Try misbehaving when they happen to use foldRight or other method in a third-party library which they not able to control?
Or are you suggesting that Try and Future should not use NonFatal?
(all the questions apply to OOM as well, i believe)
--
You received this message because you are subscribed to the Google Groups
"scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an
Hi Ale,On Sat, May 25, 2013 at 4:05 AM, Aleh Aleshka <oleg...@gmail.com> wrote:
Hi Victor
How would this benefit users of Try, Future and NonFatal?I think that's pretty clear by now.
Decrease data corruption chances by a factor so small that nor you nor twitter engineers considered to be greater than zero until this week?Do you have any references for that statement?
Increase chances that scala users will see hanging Futures and Try misbehaving when they happen to use foldRight or other method in a third-party library which they not able to control?As proven earlier, SOE is not safe to ignore, or to pretend like everything is ok. and there is no way of knowing if it is OK.Or are you suggesting that Try and Future should not use NonFatal?What is the argument that they shouldn't?(all the questions apply to OOM as well, i believe)All of my replies applies to OOM as well.
On Saturday, May 25, 2013 12:48:13 PM UTC+3, √iktor Klang wrote:Hi Ale,On Sat, May 25, 2013 at 4:05 AM, Aleh Aleshka <oleg...@gmail.com> wrote:
Hi Victor
How would this benefit users of Try, Future and NonFatal?I think that's pretty clear by now.Care to elaborate? Don't you see negative consequences for users?E.g. how is getting TimeoutException from Await is better than getting the error that caused the computation to fail?I could probably see your point if you suggested to terminate the vm on SOE or OOME, but we don't even have a way to know if there was SOE/OOME if we just make Try and Future ignore them.
Decrease data corruption chances by a factor so small that nor you nor twitter engineers considered to be greater than zero until this week?Do you have any references for that statement?Citing you: "I talked to multiple JVM vendors who said SOE was clean."Citing scaladoc:" * ''Note'': only non-fatal exceptions are caught by the combinators on `Try` (see [[scala.util.control.NonFatal]]).
* Serious system errors, on the other hand, will be thrown.
* `Try` comes to the Scala standard library after years of use as an integral part of Twitter's stack.
"
Increase chances that scala users will see hanging Futures and Try misbehaving when they happen to use foldRight or other method in a third-party library which they not able to control?As proven earlier, SOE is not safe to ignore, or to pretend like everything is ok. and there is no way of knowing if it is OK.Or are you suggesting that Try and Future should not use NonFatal?What is the argument that they shouldn't?(all the questions apply to OOM as well, i believe)All of my replies applies to OOM as well.Can we perhaps have configurable definition of NonFatal for Try? Something like scala.util.control.Exception#handling
On Tue, 28 May 2013 22:34:24 +0300, √iktor Ҡlang <viktor...@gmail.com> wrote:You just said that default unhandledException handler is not implemented properly.
On Tue, May 28, 2013 at 9:22 PM, Aleh Aleshka <oleg...@gmail.com> wrote:
On Saturday, May 25, 2013 12:48:13 PM UTC+3, √iktor Klang wrote:
Hi Ale,Care to elaborate? Don't you see negative consequences for users?
On Sat, May 25, 2013 at 4:05 AM, Aleh Aleshka <oleg...@gmail.com> wrote:
Hi Victor
How would this benefit users of Try, Future and NonFatal?
I think that's pretty clear by now.
E.g. how is getting TimeoutException from Await is better than getting the
error that caused the computation to fail?
I could probably see your point if you suggested to terminate the vm on
SOE or OOME, but we don't even have a way to know if there was SOE/OOME if
we just make Try and Future ignore them.
A properly implemented unhandledException handler is all it takes:
https://github.com/scala/scala/blob/v2.10.1/src/library/scala/concurrent/impl/Future.scala#L29
(This is what Akka does)
And suggested that every user should reimplement it and catch Error themselves.
Why do this instead of handling properly inside of library?
And what do you suggest for Try? Wrap it in try catch?
And as far as i can see akka uses scala.concurrent.ExecutionContext$#defaultReporter which just prints stacktrace everywhere, please point to me the place where it reimplements unhandledException handler.
Not sure what you were trying to say with your link btw.
Thanks, Aleh
I was surprised seeing OOME not being handled by Try. And I don't see any way to override that behavior.
Not sure i follow. Can you rethrow anything in Future.apply?
And as far as i can see akka uses scala.concurrent.**ExecutionContext$#**defaultReporter
which just prints stacktrace everywhere, please point to me the place where
it reimplements unhandledException handler.
Not sure what you were trying to say with your link btw.
Perhaps we're miscommunicationg, are you suggesting completing future
(wrapped) and try (wrapped) AND rethrowing in Future.apply and Try.apply?
If so, that's definitely something that could be considered. The key being
that it needs to travel to the UEH.
Cheers,
√
Thanks, Aleh
I have had a few cases where catching OOME is necessary.
Although OOME can never be _guaranteed_ to be the fault of your thread, it often is. If you try and allocate a 1GB array and get one, it definitely is. It is generally safe to assume that if you are allocating a large array (~100K or more) and it fails, that it is safe to catch and do some work -- such as attempt a safe shutdown on an application to persist some state to disk. The OOME is saying either "you're screwed" or "you attempted to allocate something massive". The response to those two conditions is not the same.
When reading binary serialized data, some formats prefix their strings or arrays with the length of the string or array. If that data is being read from network or disk, but is corrupted, it can easily trigger an attempt to allocate a very large array. A strategy to handle the situation by catching OOME and examining the data stream more carefully to decide how to proceed is perfectly valid strategy, but you must be able to catch OOME.
My conclusion is simple: although SOE and OOME can not be relied upon to be safe or consistent in behavior, there are (very rare) times when one will wish to at least attempt to handle them.
OOME is easier -- if your catch executes, it executes, if it leads to another OOME, you're very likely toast.
It is generally safe to assume that if you are allocating a large array (~100K or more) and it fails, that it is safe to catch and do some work -- such as attempt a safe shutdown on an application to persist some state to disk.
The OOME is saying either "you're screwed" or "you attempted to allocate something massive". The response to those two conditions is not
the same.
When reading binary serialized data, some formats prefix their strings or arrays with the length of the string or array. If that data is being read from network or disk, but is corrupted, it can easily trigger an attempt to allocate a very large array. A strategy to handle the situation by catching OOME and examining the data stream more carefully to decide how to proceed is perfectly valid strategy, but you must be able to catch OOME.
My conclusion is simple: although SOE and OOME can not be relied upon to be safe or consistent in behavior, there are (very rare) times when one will wish to at least attempt to handle them.
OOME is easier -- if your catch executes, it executes, if it leads to another OOME, you're very likely toast.
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Just to be sure we are on the same page.
The fact that a thread got OOME does not mean that there is less memory in the system after it.
In other words available memory is not affected by failed allocations.
Actually after OOME was thrown you are likely to get some additional free memory because it is likely that previously allocated stuff in this thread is now unreachable.
Using a wrapper around Try and Future might be a solution to overcome NonFatal deficiencies, but meh...
For more options, visit https://groups.google.com/groups/opt_out.
For more options, visit https://groups.google.com/groups/opt_out.
--You received this message because you are subscribed to a topic in the Google Groups "scala-language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scala-language/eC9dqTTBYHg/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to scala-language+unsubscribe@googlegroups.com.
On Wed, May 29, 2013 at 9:04 AM, Scott Carey <scott...@gmail.com> wrote:
I have had a few cases where catching OOME is necessary.
Although OOME can never be _guaranteed_ to be the fault of your thread, it often is. If you try and allocate a 1GB array and get one, it definitely is.Only if your app only has 1 thread, since other threads could get OOMEs simultaneously.
It is generally safe to assume that if you are allocating a large array (~100K or more) and it fails, that it is safe to catch and do some work -- such as attempt a safe shutdown on an application to persist some state to disk.So in that case you do your work in your own try-catch.
On Wednesday, May 29, 2013 1:33:22 AM UTC-7, √iktor Klang wrote:On Wed, May 29, 2013 at 9:04 AM, Scott Carey <scott...@gmail.com> wrote:
I have had a few cases where catching OOME is necessary.
Although OOME can never be _guaranteed_ to be the fault of your thread, it often is. If you try and allocate a 1GB array and get one, it definitely is.Only if your app only has 1 thread, since other threads could get OOMEs simultaneously.
The situation I have in mind is multi-threaded. At least Sun/Oracle's JVM will only throw the error on the one thread where the failed allocation occurs.
The app I have in mind where I ran into this was a high throughput multi-threaded application, which was occasionally reading corrupt serialized data and attempting large allocations. The only OOMEs we saw (even under stress tests with 100's of concurrent threads) were on the threads attempting these big allocations. What is more interesting is that the JVM wasn't smart enough to see that its max heap was not large enough for the allocation, and in each case it triggered, and completed, a full GC before throwing the error, even though the GC could never have succeeded.
This was a huge performance problem for this app, even if it recovered from the OOME the full GC killed throughput and caused large outliers in latency.
At least Sun's JVM lives up to the OOME documentation and only throws the OOME after trying rather hard to free up the memory with a full GC. When after that GC there is still no room for the allocation, the OOME is thrown. If the OOME is for a large allocation, it is extremely unlikely that any other threads doing small allocations will fail as a result of the large allocation.
It is generally safe to assume that if you are allocating a large array (~100K or more) and it fails, that it is safe to catch and do some work -- such as attempt a safe shutdown on an application to persist some state to disk.So in that case you do your work in your own try-catch.
I am not commenting on what the right approach in Scala is, only providing examples from my experience where the "Never catch an Error" rule does not apply.
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "scala-language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scala-language/eC9dqTTBYHg/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to scala-languag...@googlegroups.com.
OOME is easier -- if your catch executes, it executes, if it leads to another OOME, you're very likely toast.