future hangs

View: New views
12 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

Re: future hangs

by Daniel Sobral :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

MMmmm. Cool stuff. I considered the other day making a getoptions class, but this is far better!

On Wed, Jul 8, 2009 at 10:07 AM, Josh Suereth <joshua.suereth@...> wrote:


On Wed, Jul 8, 2009 at 9:03 AM, Viktor Klang <viktor.klang@...> wrote:
Remove Application in 2.8?

+30
 
Although, I'd rather see it replaced by something like David MacIver's "Optional" library: http://github.com/DRMacIver/optional/tree/master

- Josh



--
Daniel C. Sobral

Something I learned in academia: there are three kinds of academic reviews: review by name, review by reference and review by value.

Re: future hangs

by Ricky Clarkson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Typing Ctrl-Break in the console window where you invoked the JVM from
gives you a dump of all thread stacks, including what objects each
locks.  It often detects deadlocks and explicitly points them out.
Thus a deadlock 'tells you' exactly what went wrong and where too.

If you can't type Ctrl-Break because you're in an IDE, send the
process the QUIT signal (no, this does not kill the process), e.g.,
kill -QUIT 12345.

If you can't send the process the QUIT signal because you're on the
wrong OS, there's a button in the Run window to do it in IDEA.  There
isn't in Netbeans or Eclipse.  Why are you using those IDEs again?

2009/7/8 Naftoli Gugenhem <naftoligug@...>:

> I'm not sure what you mean by unrecoverable. You can catch an exception -- but if you're smart enough to think about catching it you know that you're causing it in the first place. (Although if the exception is caught by an outer code block that's agnostic of your erroneous implementation then you have to some extent recovered.)
> In any case, who wouldn't prefer a terminating exception to a hanging deadlock? An exception tells you exactly what went wrong and where it went wrong.
> Although if it's slow, like you say, then I agree that it may be too much of a price to pay to save the unwise from mysterious hangs...
>
> -------------------------------------
> Jim Andreou<jim.andreou@...> wrote:
>
> That check would (slowly, did I mention?) transform a deadlock to an
> exception - but both are unrecoverable conditions which require stopping and
> fixing the code anyway.
> 2009/7/8 Naftoli Gugenhem <naftoligug@...>
>
>> So the safety is not worth the "ugliness" for thread-based utilities such
>> as future to check for it? As someone pointed out, such bugs can come even
>> without Application.
>> (I'm suggesting the check for the library, not for user code. Also, I
>> suppose someone might be able to put such a check for these methods in an
>> aspect...)
>> -------------------------------------
>> Jim Andreou<jim.andreou@...> wrote:
>>
>> Yeah, but it's ultra ugly. Search for a <clinit> method in the stack trace.
>> Then sue yourself for doing it.
>> 2009/7/8 Naftoli Gugenhem <naftoligug@...>
>>
>> > Is there any way to detect if code is running in a static initialization?
>> >
>> > -------------------------------------
>> > Christos KK Loverdos<loverdos@...> wrote:
>> >
>> > lol
>> >
>> > [Incidentally, I have just returned from a trip to Sparta :-) .]
>> >
>> >
>> > On Jul 8, 2009, at 4:12 PM, Jim Andreou wrote:
>> >
>> > > +300
>> > >
>> > > - This is blasphemy! This is madness!
>> > > - This is Scalta!
>> > >
>> > > 2009/7/8 Josh Suereth <joshua.suereth@...>
>> > >
>> > >
>> > > On Wed, Jul 8, 2009 at 9:03 AM, Viktor Klang
>> > > <viktor.klang@...> wrote:
>> > > Remove Application in 2.8?
>> > >
>> > > +30
>> > >
>> > > Although, I'd rather see it replaced by something like David
>> > > MacIver's "Optional" library:
>> > http://github.com/DRMacIver/optional/tree/master
>> > >
>> > > - Josh
>> > >
>> >
>> > --
>> >  __~O
>> > -\ <,       Christos KK Loverdos
>> > (*)/ (*)      http://ckkloverdos.com
>> >
>> >
>> >
>> >
>> >
>> >
>>
>



--
Ricky Clarkson
Java Programmer, AD Holdings
+44 1565 770804
Skype: ricky_clarkson
Google Talk: ricky.clarkson@...

Re: future hangs

by Erik Engbrecht :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

+1

On Wed, Jul 8, 2009 at 9:03 AM, Viktor Klang <viktor.klang@...> wrote:
Remove Application in 2.8?


On Wed, Jul 8, 2009 at 2:55 PM, Jim Andreou <jim.andreou@...> wrote:
But the problem isn't the constructor, it's the class initialization.

2009/7/8 Marcus Downing <marcus@...>


Is removing Application sufficient? The idiom that Application embodies is
bound to happen again in other people's code. Shouldn't either the creation
or accessing of the future throw an exception, if called from within a
constructor?



Ricky Clarkson wrote:
>
> Yet again, "let's remove Application".
>
> 2009/7/8 Detering Dirk <Dirk.Detering@...>:
>> Nice subject ...
>>
>>> This simple application hangs at "println(s())". Apparently,
>>> the mistake is so simple that I cannot find it... what am I
>>> doing wrong? Defining getData and printing s() in the
>>> interactive scala shell works just fine. Thanks!
>>>
>>> object Test extends Application {
>>>
>>>     val s = future(getData("AAPL\n"))
>>>     val t = getData("INTC\n")
>>>     println(t) // that's fine
>>>     println(s()) // hangs here
>>
>> Well, the println(s()) will first wait for the result of s,
>> but -due to the definition of s- that doesn't come now, but
>> in future.
>>
>> Due to the functional aspect, this is true for every point in time.
>>
>> (I would recommend renaming the val s into val godot,
>> and then putting the println(godot()) into a method called
>> "mañana"...).
>>
>>
>> Ðet
>>
>>
>> PS: No, I'm NOT stressed, Mum!!!!
>>
>
>
>
> --
> Ricky Clarkson
> Java Programmer, AD Holdings
> +44 1565 770804
> Skype: ricky_clarkson
> Google Talk: ricky.clarkson@...
>
>

--
View this message in context: http://www.nabble.com/future-hangs-tp24383831p24390827.html
Sent from the Scala - User mailing list archive at Nabble.com.





--
Viktor Klang
Scala Loudmouth



--
http://erikengbrecht.blogspot.com/

Parent Message unknown Re: future hangs

by Naftoli Gugenheim :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Good to know. How does this IDEA command work on Windows?

-------------------------------------
Ricky Clarkson<ricky.clarkson@...> wrote:

Typing Ctrl-Break in the console window where you invoked the JVM from
gives you a dump of all thread stacks, including what objects each
locks.  It often detects deadlocks and explicitly points them out.
Thus a deadlock 'tells you' exactly what went wrong and where too.

If you can't type Ctrl-Break because you're in an IDE, send the
process the QUIT signal (no, this does not kill the process), e.g.,
kill -QUIT 12345.

If you can't send the process the QUIT signal because you're on the
wrong OS, there's a button in the Run window to do it in IDEA.  There
isn't in Netbeans or Eclipse.  Why are you using those IDEs again?

2009/7/8 Naftoli Gugenhem <naftoligug@...>:

> I'm not sure what you mean by unrecoverable. You can catch an exception -- but if you're smart enough to think about catching it you know that you're causing it in the first place. (Although if the exception is caught by an outer code block that's agnostic of your erroneous implementation then you have to some extent recovered.)
> In any case, who wouldn't prefer a terminating exception to a hanging deadlock? An exception tells you exactly what went wrong and where it went wrong.
> Although if it's slow, like you say, then I agree that it may be too much of a price to pay to save the unwise from mysterious hangs...
>
> -------------------------------------
> Jim Andreou<jim.andreou@...> wrote:
>
> That check would (slowly, did I mention?) transform a deadlock to an
> exception - but both are unrecoverable conditions which require stopping and
> fixing the code anyway.
> 2009/7/8 Naftoli Gugenhem <naftoligug@...>
>
>> So the safety is not worth the "ugliness" for thread-based utilities such
>> as future to check for it? As someone pointed out, such bugs can come even
>> without Application.
>> (I'm suggesting the check for the library, not for user code. Also, I
>> suppose someone might be able to put such a check for these methods in an
>> aspect...)
>> -------------------------------------
>> Jim Andreou<jim.andreou@...> wrote:
>>
>> Yeah, but it's ultra ugly. Search for a <clinit> method in the stack trace.
>> Then sue yourself for doing it.
>> 2009/7/8 Naftoli Gugenhem <naftoligug@...>
>>
>> > Is there any way to detect if code is running in a static initialization?
>> >
>> > -------------------------------------
>> > Christos KK Loverdos<loverdos@...> wrote:
>> >
>> > lol
>> >
>> > [Incidentally, I have just returned from a trip to Sparta :-) .]
>> >
>> >
>> > On Jul 8, 2009, at 4:12 PM, Jim Andreou wrote:
>> >
>> > > +300
>> > >
>> > > - This is blasphemy! This is madness!
>> > > - This is Scalta!
>> > >
>> > > 2009/7/8 Josh Suereth <joshua.suereth@...>
>> > >
>> > >
>> > > On Wed, Jul 8, 2009 at 9:03 AM, Viktor Klang
>> > > <viktor.klang@...> wrote:
>> > > Remove Application in 2.8?
>> > >
>> > > +30
>> > >
>> > > Although, I'd rather see it replaced by something like David
>> > > MacIver's "Optional" library:
>> > http://github.com/DRMacIver/optional/tree/master
>> > >
>> > > - Josh
>> > >
>> >
>> > --
>> >  __~O
>> > -\ <,       Christos KK Loverdos
>> > (*)/ (*)      http://ckkloverdos.com
>> >
>> >
>> >
>> >
>> >
>> >
>>
>



--
Ricky Clarkson
Java Programmer, AD Holdings
+44 1565 770804
Skype: ricky_clarkson
Google Talk: ricky.clarkson@...

Re: future hangs

by Randall Schulz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wednesday July 8 2009, Naftoli Gugenhem wrote:
> Good to know. How does this IDEA command work on Windows?

Do you see the little camera icon in the Run window? It's there in the
Linux version and the documentation (on-line help) doesn't mention that
it's a Linux-only thing.


Randall Schulz


> -------------------------------------
> Ricky Clarkson<ricky.clarkson@...> wrote:
>
> Typing Ctrl-Break in the console window where you invoked the JVM
> from gives you a dump of all thread stacks, including what objects
> each locks.  It often detects deadlocks and explicitly points them
> out. Thus a deadlock 'tells you' exactly what went wrong and where
> too.
>
> If you can't type Ctrl-Break because you're in an IDE, send the
> process the QUIT signal (no, this does not kill the process), e.g.,
> kill -QUIT 12345.
>
> If you can't send the process the QUIT signal because you're on the
> wrong OS, there's a button in the Run window to do it in IDEA.  There
> isn't in Netbeans or Eclipse.  Why are you using those IDEs again?
>
> ...

Parent Message unknown Re: future hangs

by Naftoli Gugenheim :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I don't have IDEA. What I meant to ask is, I thought Windows doesn't have the linux concept of signals, so how does it simulate Ctrl-Break?

-------------------------------------
Randall R Schulz<rschulz@...> wrote:

On Wednesday July 8 2009, Naftoli Gugenhem wrote:
> Good to know. How does this IDEA command work on Windows?

Do you see the little camera icon in the Run window? It's there in the
Linux version and the documentation (on-line help) doesn't mention that
it's a Linux-only thing.


Randall Schulz


> -------------------------------------
> Ricky Clarkson<ricky.clarkson@...> wrote:
>
> Typing Ctrl-Break in the console window where you invoked the JVM
> from gives you a dump of all thread stacks, including what objects
> each locks.  It often detects deadlocks and explicitly points them
> out. Thus a deadlock 'tells you' exactly what went wrong and where
> too.
>
> If you can't type Ctrl-Break because you're in an IDE, send the
> process the QUIT signal (no, this does not kill the process), e.g.,
> kill -QUIT 12345.
>
> If you can't send the process the QUIT signal because you're on the
> wrong OS, there's a button in the Run window to do it in IDEA.  There
> isn't in Netbeans or Eclipse.  Why are you using those IDEs again?
>
> ...

Re: future hangs

by Geoff Reedy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Jul 08, 2009 at 03:31:17PM -0700, Naftoli Gugenhem said
> I don't have IDEA. What I meant to ask is, I thought Windows doesn't have the linux concept of signals, so how does it simulate Ctrl-Break?

If I remember correctly at the windows command line pressing CTRL-Break
dumps the JVM information. In most cases sending the QUIT signal to a
program in unix to get that information is done by pressing CTRL-\ at
its controlling terminal.

-- Geoff Reedy

Re: future hangs

by Gordon Tyler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Naftoli Gugenhem wrote:
> I don't have IDEA. What I meant to ask is, I thought Windows doesn't have the linux concept of signals, so how does it simulate Ctrl-Break?

I think Windows does have something similar to Linux signals. Ctrl-Break
does get translated by CMD into some sort of signal sent to the current
process, so I would imagine that IDEA can send the same signal.

I remember seeing C code in one of the projects at work which handled
the Ctrl-Break signal.

Ciao,
Gordon

Re: future hangs

by Dimitris Andreou :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In case it's useful to anyone, one can just fire jconsole up, choose the process to connect, go to "threads" tab and click "deadlock detection" (but even merely peeking what each thread is doing is interesting too)

2009/7/9 Gordon Tyler <gordon@...>
Naftoli Gugenhem wrote:
I don't have IDEA. What I meant to ask is, I thought Windows doesn't have the linux concept of signals, so how does it simulate Ctrl-Break?

I think Windows does have something similar to Linux signals. Ctrl-Break does get translated by CMD into some sort of signal sent to the current process, so I would imagine that IDEA can send the same signal.

I remember seeing C code in one of the projects at work which handled the Ctrl-Break signal.

Ciao,
Gordon


Re: future hangs

by Johannes Rudolph-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Jul 9, 2009 at 12:54 AM, Gordon Tyler<gordon@...> wrote:
> I think Windows does have something similar to Linux signals. Ctrl-Break
> does get translated by CMD into some sort of signal sent to the current
> process, so I would imagine that IDEA can send the same signal.

FYI: See https://openjdk.dev.java.net/source/browse/openjdk/jdk/trunk/hotspot/src/os/windows/vm/os_windows.cpp?rev=257&view=markup

for the OpenJDK Windows implementation of signals. You can register a
SetConsoleCtrlHandler to handle console events. Hotspot registers a
handler (consoleHandler) and simulates fine grained signals based on
this.

Johannes

-----------------------------------------------
Johannes Rudolph
http://virtual-void.net

Re: future hangs

by Ricky Clarkson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It appears to insert its own code as a thread in your program, because
triggerCtrlBreak in some IDEA-specific class is present in the thread
dump.  I heard that that's a native method but haven't looked into it.

2009/7/8 Naftoli Gugenhem <naftoligug@...>:

> I don't have IDEA. What I meant to ask is, I thought Windows doesn't have the linux concept of signals, so how does it simulate Ctrl-Break?
>
> -------------------------------------
> Randall R Schulz<rschulz@...> wrote:
>
> On Wednesday July 8 2009, Naftoli Gugenhem wrote:
>> Good to know. How does this IDEA command work on Windows?
>
> Do you see the little camera icon in the Run window? It's there in the
> Linux version and the documentation (on-line help) doesn't mention that
> it's a Linux-only thing.
>
>
> Randall Schulz
>
>
>> -------------------------------------
>> Ricky Clarkson<ricky.clarkson@...> wrote:
>>
>> Typing Ctrl-Break in the console window where you invoked the JVM
>> from gives you a dump of all thread stacks, including what objects
>> each locks.  It often detects deadlocks and explicitly points them
>> out. Thus a deadlock 'tells you' exactly what went wrong and where
>> too.
>>
>> If you can't type Ctrl-Break because you're in an IDE, send the
>> process the QUIT signal (no, this does not kill the process), e.g.,
>> kill -QUIT 12345.
>>
>> If you can't send the process the QUIT signal because you're on the
>> wrong OS, there's a button in the Run window to do it in IDEA.  There
>> isn't in Netbeans or Eclipse.  Why are you using those IDEs again?
>>
>> ...
>



--
Ricky Clarkson
Java Programmer, AD Holdings
+44 1565 770804
Skype: ricky_clarkson
Google Talk: ricky.clarkson@...

Re: future hangs

by Cormac Blackwell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You can use jstack from the JDK to get you the thread dump.

Cormac

< Prev | 1 - 2 | Next >