bugGNU Octave - Bugs: bug #55185, KBHIT(1) should return...

 
 

bug #55185: KBHIT(1) should return immediately. It takes 8+ hours instead:

Submitted by:  Dave Goel <deego>
Submitted on:  Sat 08 Dec 2018 03:27:20 AM UTC  
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error
Status:  Duplicate Assigned to:  None
Originator Name:  deego Open/Closed:  Closed
Release:  4.2.2 Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Tue 11 Dec 2018 02:22:17 AM UTC, comment #7: 

Closed.

Mike Miller <mtmiller>
Project Administrator
Tue 11 Dec 2018 01:45:21 AM UTC, comment #6: 

Mike,

Thanks.

This is octave on xfce4-terminal, invoked as octave-gui --no-gui. The terminal is focused and visible. By #55196, I figured out that the bug is not in kbhit per se, so will you close this bug? The program execution simply halts whichever instruction it is on. All you need is for some figure to be present somewhere (drawn, say, at the beginning of the program)>

I have to invoke using octave-gui as such because I need to be able to use the QT toolkit. (Other toolkits lead to blank figures if a figure is sent from a running program).

Dave

Dave Goel <deego>
Tue 11 Dec 2018 01:25:24 AM UTC, comment #5: 

As with bug #55196, the screen lock does not affect the running of the example program at all on my system (GNOME desktop environment instead of Xfce). The program continues to run, continues to beep while the screen is locked, and no error output is shown on the Octave console.

Just for completeness, is this Octave with or without the GUI? If non-GUI, which terminal emulator? Is the terminal emulator focused and visible? Do you have an alternative window manager or desktop environment you can compare behavior against?

Mike Miller <mtmiller>
Project Administrator
Mon 10 Dec 2018 08:41:06 PM UTC, comment #4: 

Hi Carnë Draug <carandraug>,

Thanks.

re your query: No, the issue is that the lock happens when also plotting.  It is the attempt to plot while locking that somehow makes queues hang. And, that's when the kbhit queue hangs. And, octave should return immediately anyway, but it doesn't.

(My ssscce had to reproduce the trifecta of these conditions, which would explain why it's just a bit verbose(your irc comment))

Dave Goel <deego>
Mon 10 Dec 2018 01:01:11 PM UTC, comment #3: 

To make sure the I got the issue properly, the report is that under xfce4 with locked screen, kbhit(1) does not return immediately and waits until the screen is unlocked?

If that's so, then this script:

function time_kbhit
  tic();
  kbhit (1);
  printf ('took %f', toc ());
endfunction

pause(5);
## then look screen and wait a long time
time_kbhit ()

should display a very large number. I locked my screen (gnome 3.30) between the pause (5) and time kbhit and got 0.000403 so I can't reproduce it.

Carnë Draug <carandraug>
Project Member
Sun 09 Dec 2018 09:13:23 PM UTC, comment #2: 

Workaround: I find it much more stable to interact with a computing octave instance via the file system. Specifically, just in your situation I have periodically checked for the existence of a file named "stop", in which case I made the script terminate gracefully.

Michael Leitner <mleitner>
Sat 08 Dec 2018 04:21:19 AM UTC, comment #1: 

For what it is worth:
I can have a locked blank screen and the sound keeps beeping.
Ubuntu 18.04

Doug Stewart <dastew>
Sat 08 Dec 2018 03:27:20 AM UTC, original submission:  

Your giant computation takes 30 days, so

(1) You want to plot the results intermittently, so you are stuck with using the qt- toolkit.[1]

(2) If user presses "T", your running program wishes to detect the keypress, and do certain actions [save work, terminate gracefully, etc.]

(3) Unfortunately, you occasionally do have to go home to shower during these 30 days, and for security, you have to allow the screensaver to lock the screen when you go home.

Your boss is strange and thinks that those are some pretty reasonable minimal set of requirements your program should have.
Here's a SSCCE that shows how kbhit(1) hangs forever when you try these things:

(a) Debian Stable, self-compiled octave 4.22, xfce4.
(b) start octave --no-gui [which uses qt by default] and run the SSCCE below: yyybug008. You start hearing a beep and see a plot after every intermediate result.  Better yet, start several octave's.
(c) That's it. Congfigure xfce4 to lock monitor within 1 minute. Disable all hibernating/sleeping. Indeed, your other scripts - including octave ones - keep working during the monitor-sleep, confirming that your system was alive and kicking all this time!
(d) Wait a minute and your screen locks. Almost immediately, you stop hearing any beeps. Wait upto 1-5 minutes if you still hear them.
(e) Unlock the screen after the beeps stop or after you take that shower. Each octave has errored out because it detected that kbhit(1) was hung instead of returning immediately. I have seen hangs of 8 hours - or however long I leave the screen locked. Thus, all work stops when the screen locks. :(

[1] If you use any other toolkit, then the plotted figure either doesn't show till the end of 30 days, or if it does, it gets lost very easily: You alt-tab or switch workspace, and you now have a blank figure.

function  yyybug008();
  while true;
    for mmm=1:100;
      ig = __kbhitcheck;
    endfor
    plot(rand(1,2), rand(1,2));
    hold off;
    pause(2+rand());
    system("beep");
  endwhile
endfunction

function out = __kbhitcheck;
  ticcer=tic();
  out=kbhit(1);
  timetaken = toc(ticcer);
  if timetaken>1;
    error(sprintf("kbhit(1) should have taken negligible time, but took %f seconds.", timetaken));
  endif
endfunction

Dave Goel <deego>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mleitner (Posted a comment)
  • -email is unavailable- added by dastew (Posted a comment)
  • -email is unavailable- added by deego (Submitted the item)
  • -email is unavailable- added by deego
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-12-11 mtmiller StatusWorks For Me => Duplicate
        Open/ClosedOpen => Closed
    2018-12-11 mtmiller StatusNone => Works For Me
    2018-12-08 deego Carbon-Copy- => Added deego3@gmail.com

    Back to the top


    Powered by Savane 3.5