Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

Poking about issue 1677

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


jeanpierreda at gmail

Jun 26, 2012, 3:51 AM

Post #1 of 7 (405 views)
Permalink
Poking about issue 1677

Hi guys,

I just wanted to bring some more attention to issue #1677 , because I
feel it's important and misunderstood. See:
http://bugs.python.org/issue1677

The issue is that sometimes, if you press ctrl-c on Windows, instead
of raising a KeyboardInterrupt, Python will exit completely. Because
of this, any program that relies on ctrl-c/KeyboardInterrupt is not
guaranteed to work on windows. Also, working with the interactive
interpreter becomes really annoying for those with the habit of
deleting the whole input line via ctrl-c.

Some people that read the bug report think that this only happens if
you hold down ctrl-c long enough or fast enough or some such thing.
That's not so; it can happen just from pressing ctrl-c once. Whatever
race condition here is not related to the timing gaps between presses
of ctrl-c. The "test cases" of "hold down ctrl-c for a bit" are to
conveniently reproduce, not a description of the problem.

Hope this was the right place. #python-dev encouraged me to post here,
so, yeah. And thanks for all your hard work making Python a pleasant
place to be. :)

-- Devin
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


mail at timgolden

Jun 26, 2012, 3:59 AM

Post #2 of 7 (379 views)
Permalink
Re: Poking about issue 1677 [In reply to]

On 26/06/2012 11:51, Devin Jeanpierre wrote:
> Hi guys,
>
> I just wanted to bring some more attention to issue #1677 , because I
> feel it's important and misunderstood. See:
> http://bugs.python.org/issue1677
>
> The issue is that sometimes, if you press ctrl-c on Windows, instead
> of raising a KeyboardInterrupt, Python will exit completely. Because
> of this, any program that relies on ctrl-c/KeyboardInterrupt is not
> guaranteed to work on windows. Also, working with the interactive
> interpreter becomes really annoying for those with the habit of
> deleting the whole input line via ctrl-c.
>
> Some people that read the bug report think that this only happens if
> you hold down ctrl-c long enough or fast enough or some such thing.
> That's not so; it can happen just from pressing ctrl-c once. Whatever
> race condition here is not related to the timing gaps between presses
> of ctrl-c. The "test cases" of "hold down ctrl-c for a bit" are to
> conveniently reproduce, not a description of the problem.
>
> Hope this was the right place. #python-dev encouraged me to post here,
> so, yeah. And thanks for all your hard work making Python a pleasant
> place to be. :)

Thanks, Devin. Definitely useful info. AFAICT you haven't added that
particular snippet of info to the call. (ie the fact that even one press
will trigger the issue). Please feel free to add; I notice that you're
the last submitter, some time last year.

Goodness knows if I'll get the time, but the
natural thing would be to hunt down the uses of SetConsoleCtrlHandler to
see what we're doing with them.

TJG
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


martin at v

Jun 26, 2012, 4:21 AM

Post #3 of 7 (379 views)
Permalink
Re: Poking about issue 1677 [In reply to]

> I just wanted to bring some more attention to issue #1677 , because I
> feel it's important and misunderstood.

Please consider working even more on a solution then. If I had time to
work on this, I'd run Python in a debugger, and see what happens. Finding
out in what state Python is when it stops might be enough to create a
solution.

I find this very hard to reproduce. All of the versions reported to crash
work fine for me most of the time, except that a small percentage (1 out
of 5 starts perhaps) actually does crash.

Regards,
Martin


_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


mail at timgolden

Jun 26, 2012, 4:28 AM

Post #4 of 7 (378 views)
Permalink
Re: Poking about issue 1677 [In reply to]

On 26/06/2012 11:59, Tim Golden wrote:
> On 26/06/2012 11:51, Devin Jeanpierre wrote:
>> Hi guys,
>>
>> I just wanted to bring some more attention to issue #1677 , because I
>> feel it's important and misunderstood. See:
>> http://bugs.python.org/issue1677
>>
>> The issue is that sometimes, if you press ctrl-c on Windows, instead
>> of raising a KeyboardInterrupt, Python will exit completely. Because
>> of this, any program that relies on ctrl-c/KeyboardInterrupt is not
>> guaranteed to work on windows. Also, working with the interactive
>> interpreter becomes really annoying for those with the habit of
>> deleting the whole input line via ctrl-c.
>>
>> Some people that read the bug report think that this only happens if
>> you hold down ctrl-c long enough or fast enough or some such thing.
>> That's not so; it can happen just from pressing ctrl-c once. Whatever
>> race condition here is not related to the timing gaps between presses
>> of ctrl-c. The "test cases" of "hold down ctrl-c for a bit" are to
>> conveniently reproduce, not a description of the problem.
>>
>> Hope this was the right place. #python-dev encouraged me to post here,
>> so, yeah. And thanks for all your hard work making Python a pleasant
>> place to be. :)
>
> Thanks, Devin. Definitely useful info. AFAICT you haven't added that
> particular snippet of info to the call. (ie the fact that even one press
> will trigger the issue). Please feel free to add; I notice that you're
> the last submitter, some time last year.
>
> Goodness knows if I'll get the time, but the
> natural thing would be to hunt down the uses of SetConsoleCtrlHandler to
> see what we're doing with them.

OK. We clearly *don't* set a console handler as I thought
we did. Scratch that idea off the list. As Martin said:
need to run this with a debugger attached to try to catch
in action.

TJG
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


tjreedy at udel

Jun 26, 2012, 12:02 PM

Post #5 of 7 (369 views)
Permalink
Re: Poking about issue 1677 [In reply to]

On 6/26/2012 6:51 AM, Devin Jeanpierre wrote:

> The issue is that sometimes, if you press ctrl-c on Windows, instead
> of raising a KeyboardInterrupt, Python will exit completely. Because
> of this, any program that relies on ctrl-c/KeyboardInterrupt is not
> guaranteed to work on windows. Also, working with the interactive
> interpreter becomes really annoying for those with the habit of
> deleting the whole input line via ctrl-c.

Idle Shell, 3.3.0a4, Win 7does not seem to have this problem. Still up
after 6000 ^Cs. It is better anyway, in multiple ways, than Command
Prompt. (That does not help batch-mode programs, though.)

That aside, perhaps the way it handles ^C might help.

I did get the CP to close four times, each time after a few hundred to
maybe a thousand ^Cs. It seems to require more than just one held down
key press. I suspect the closures happened after the limited line buffer
was filled and it was starting to delete the earliest lines.

--
Terry Jan Reedy

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


mail at timgolden

Jun 27, 2012, 6:35 AM

Post #6 of 7 (365 views)
Permalink
Re: Poking about issue 1677 [In reply to]

On 26/06/2012 20:02, Terry Reedy wrote:
> On 6/26/2012 6:51 AM, Devin Jeanpierre wrote:
>
>> The issue is that sometimes, if you press ctrl-c on Windows, instead
>> of raising a KeyboardInterrupt, Python will exit completely. Because
>> of this, any program that relies on ctrl-c/KeyboardInterrupt is not
>> guaranteed to work on windows. Also, working with the interactive
>> interpreter becomes really annoying for those with the habit of
>> deleting the whole input line via ctrl-c.
>
> Idle Shell, 3.3.0a4, Win 7does not seem to have this problem. Still up
> after 6000 ^Cs. It is better anyway, in multiple ways, than Command
> Prompt. (That does not help batch-mode programs, though.)
>
> That aside, perhaps the way it handles ^C might help.
>
> I did get the CP to close four times, each time after a few hundred to
> maybe a thousand ^Cs. It seems to require more than just one held down
> key press. I suspect the closures happened after the limited line buffer
> was filled and it was starting to delete the earliest lines.
>

I've just updated the call with as much as I had time for just now.

Your point about IDLE made me think; I installed pyreadline
and now I can't get it to fail at all. Seems to point even
more to myreadline.c.

More later

TJG
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


mail at timgolden

Jun 27, 2012, 11:52 AM

Post #7 of 7 (363 views)
Permalink
Re: Poking about issue 1677 [In reply to]

I can confirm that there is a race condition between the code in
myreadline.c and the signal_handler. I have a patch in readiness which
basically loops until the signal has been tripped.

But what I don't know is: what to do if the signal *still* doesn't trip
(after 100 millisecond-retries)? At present the code just drops through
(with a comment warning) which is why we're seeing the interpreter exit.
What should happen, though? Raise SystemError?
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.