bugGNU Octave - Bugs: bug #55943, pause() with no arguments returns...

 
 

bug #55943: pause() with no arguments returns immediately on Windows

Submitter:  None
Submitted:  Mon 18 Mar 2019 03:44:16 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Performance
Status:  Fixed Assigned to:  None
Originator Name:  Alan S Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 5.1.0
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 27 Nov 2019 04:19:40 AM UTC, comment #28: 

The next major release of Octave will be 6.1 and that should occur at the end of 2019/beginning of 2020.

Rik <rik5>
Group administrator
Tue 26 Nov 2019 09:01:42 PM UTC, comment #27: 

@Pantxo: so, when we should wait a new version without the bug?

Gennadii Kondratev <gennadii>
Mon 25 Nov 2019 09:15:38 PM UTC, comment #26: 

@genadij: Yes, you precisely installed the Octave version that has this bug :-). It should be gone in the next released version.

Pantxo Diribarne <pantxo>
Group Member
Mon 25 Nov 2019 09:04:20 PM UTC, comment #25: 

I recently installed the 5.1.0 version and this bug is reproduced. The problem is not gone.

Gennadii Kondratev <gennadii>
Mon 03 Jun 2019 09:35:55 PM UTC, comment #24: 

@Philip: Great, thanks for testing.

Pantxo Diribarne <pantxo>
Group Member
Mon 03 Jun 2019 07:18:17 PM UTC, comment #23: 

Oops, I didn't grasp that the fix had been applied already on April 12 (stupid me!) so I could have tried a lot earlier.

On Windows 7 and Windows 10 I verified that the bug is there in 5.1.0. Then, with 6.0.0 builds from April 22 and May 21 the original issue works out as follows, using F9 from the editor:

>> x=0:.5:10;

>> y1=sin(x)

y1 =
 Columns 1 through 9:
   0.00000   0.47943   0.84147   0.99749   0.90930   0.59847   0.14112  -0.35078  -0.75680
 Columns 10 through 18:
  -0.97753  -0.95892  -0.70554  -0.27942   0.21512   0.65699   0.93800   0.98936   0.79849
 Columns 19 through 21:
   0.41212  -0.07515  -0.54402

>> pause;

## delay until focus on terminal and hitting a random key,
## then execution continues

>> y2=cos(x)

y2 =
 Columns 1 through 8:
   1.000000   0.877583   0.540302   0.070737  -0.416147  -0.801144  -0.989992  -0.936457
 Columns 9 through 16:
  -0.653644  -0.210796   0.283662   0.708670   0.960170   0.976588   0.753902   0.346635
 Columns 17 through 21:
  -0.145500  -0.602012  -0.911130  -0.997172  -0.839072


.. so it looks like the bug has been fixed indeed.

Closing report.

Philip Nienhuis <philipnienhuis>
Group Member
Sun 02 Jun 2019 06:44:37 PM UTC, comment #22: 

@Panxto:
I just returned from a week abroad. Somewhere this week I'll try the fix.

Philip Nienhuis <philipnienhuis>
Group Member
Wed 29 May 2019 08:39:58 AM UTC, comment #21: 

No one confirmed that this change actually fixed the issue. CCing Philip since I know he has recent builds for Windows at hand.

@Philip: Does "pause()" return immediately on recent (>April 12th) build?

Pantxo Diribarne <pantxo>
Group Member
Fri 12 Apr 2019 08:16:55 PM UTC, comment #20: 

I pushed the change under Mike's name here (https://hg.savannah.gnu.org/hgweb/octave/rev/7894624afc47).  If it doesn't work, I'm sure we'll here about it.

Rik <rik5>
Group administrator
Mon 08 Apr 2019 03:47:24 PM UTC, comment #19: 

@Mike: No one seems able to build an MXE version to test this, but your patch looks correct.  I would apply it and we can deal with any secondary consequences as they appear.

Rik <rik5>
Group administrator
Wed 03 Apr 2019 07:28:45 PM UTC, comment #18: 

I am also impacted by this bug, on Windows only, Octave 5.1.0. Looking forward to the next release with this patch.

The kbhit(); workaround is working for me for now.

Michael <scivision>
Fri 29 Mar 2019 04:30:20 PM UTC, comment #17: 

Can someone please try the attached patch in a build for Windows and see if this solves the bug?

(file #46662)

Mike Miller <mtmiller>
Group Member
Fri 29 Mar 2019 04:22:16 AM UTC, comment #16: 

I have a suspicion about this bug. It's Windows specific, which means it may be caused by the Windows specific section of code here:

https://hg.savannah.gnu.org/hgweb/octave/file/4388526646ef/libinterp/corefcn/sysdep.cc#l596

Now I don't really know how these functions work on Windows, but it looks to me like in non-blocking mode, it's either returning a valid character or the value 0 if no keys were pressed.

Can someone please test a patch on Windows that simply returns -1 instead of 0 in that ternary expression?

In the Unix section of code, the return value when no character is available is 'EOF', which is defined to be -1 in stdio.h.

Meanwhile, in the new 'octave::sleep(inf)' section of code that was added in Octave 5.1, 'octave::kbhit' is called in a loop, and any non-negative value, including 0, breaks out of the loop. So that may explain why this returns immediately on Windows.

https://hg.savannah.gnu.org/hgweb/octave/file/4388526646ef/libinterp/corefcn/utils.cc#l1295

Mike Miller <mtmiller>
Group Member
Thu 28 Mar 2019 12:00:39 AM UTC, comment #15: 

Mike: Yes, sorry. I did it again. Will try to
think first next time...

Michael Godfrey <godfrey>
Group Member
Wed 27 Mar 2019 10:55:32 PM UTC, comment #14: 

Using 'hlog -k pause' I think these changesets should be examined


changeset:   26026:511295347a27
user:        Pantxo Diribarne <pantxo.diribarne@gmail.com>
date:        Wed Oct 31 23:07:19 2018 +0100
summary:     Allow pause state to be changed (bug #53723)

changeset:   25961:f7b205562f1d
user:        Pantxo Diribarne <pantxo.diribarne@gmail.com>
date:        Mon Oct 22 16:34:06 2018 +0200
summary:     Allow graphics events to be processed while pause is active (bug #53729)



Rik <rik5>
Group administrator
Wed 27 Mar 2019 10:36:45 PM UTC, comment #13: 

Michael, you are confusing bug reports again, this bug is about 'pause()' on Windows systems returning immediately with no delay. The bug you meant to refer to is bug #55029. This bug is not the same.

Mike Miller <mtmiller>
Group Member
Wed 27 Mar 2019 10:35:17 PM UTC, comment #12: 

They are roughly equivalent, unless you care about plots.

If you have a plot active, then the intent is that 'pause()' still allows plots and graphics to be resized or zoomed or otherwise interacted with, while 'kbhit()' stops everything until a key is pressed.

Mike Miller <mtmiller>
Group Member
Wed 27 Mar 2019 10:35:15 PM UTC, comment #11: 

@Rik: The problem does appear to be in pause which is
John's code and he said he would look at it when he
can find time...

Also, it seems to depend glibc version. My system
is at glibc-2.28-26

Michael Godfrey <godfrey>
Group Member
Wed 27 Mar 2019 10:33:42 PM UTC, comment #10: 

For your usage, simply waiting for a user to press a key to continue, they are equivalent.  Try 'help kbhit' to see the documentation.


 -- kbhit ()
 -- kbhit (1)
     Read a single keystroke from the keyboard.

     If called with an argument, don't wait for a keypress.

     For example,

          x = kbhit ();

     will set X to the next character typed at the keyboard as soon as
     it is typed.

          x = kbhit (1);

     is identical to the above example, but doesn't wait for a keypress,
     returning the empty string if no key is available.

     See also: input, pause.


The kbhit function also doesn't echo the character to string (whatever it was) the way that pause does.


Rik <rik5>
Group administrator
Wed 27 Mar 2019 10:28:09 PM UTC, comment #9: 

Hi Rik.

kbhit() waits for me to hit a key into the keyboard.

The function I hope from pause().

Are these two functions interchangeable?

Daniel Pérez <dannp29>
Wed 27 Mar 2019 10:17:20 PM UTC, comment #8: 

pause() works on Linux where I can test it.  Something must have changed with the Windows implementation.

Can you try


x = kbhit ()


Does this return immediately, or wait for you to hit a key on the keyboard?

Rik <rik5>
Group administrator
Wed 27 Mar 2019 09:53:00 PM UTC, comment #7: 

All,

Are there any plans to fix this for the next rev? I do like to use pause in my work, and it would be really nice if it worked.

Alan <alans>
Tue 26 Mar 2019 03:18:09 PM UTC, comment #6: 

I can reproduce this bug, it only happens when the command is called without arguments. Otherwise, it works fine.



>> OCTAVE_VERSION
ans = 5.1.0
>> computer
x86_64-w64-mingw32
>> tic, pause(), toc
Elapsed time is 0.100191 seconds.
>> tic, pause, toc
Elapsed time is 0.100247 seconds.
>> tic, pause(5), toc
Elapsed time is 5.00048 seconds.
>> tic, pause(1), toc
Elapsed time is 1.00014 seconds.


Daniel Pérez <dannp29>
Mon 18 Mar 2019 06:58:13 PM UTC, comment #5: 

With 5.1.1 (on Windows 7), just copying the code into the terminal:

GNU Octave, version 5.1.1
:
>> x=0:.5:10;
>> y1=sin(x)
y1 =
 Columns 1 through 9:
   0.00000   0.47943   0.84147   0.99749   0.90930   0.59847   0.14112  -0.35078  -0.75680
 Columns 10 through 18:
  -0.97753  -0.95892  -0.70554  -0.27942   0.21512   0.65699   0.93800   0.98936   0.79849
 Columns 19 through 21:
   0.41212  -0.07515  -0.54402

>> pause;
>> 2=cos(x)
parse error:

  invalid constant left hand side of assignment

>>> 2=cos(x)
     ^

>>


(It seems Octave "eats" the "y" in y2, pauses, and upon hitting <Enter> reports a parse error.)

Copying the code into an empty editor tab, selecting it and running it pressing F9 I can reproduce the bug.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 18 Mar 2019 05:40:03 PM UTC, comment #4: 

This doesn't sound anything like bug #55029, not a duplicate.

Can someone with Octave on Windows reproduce this?

Mike Miller <mtmiller>
Group Member
Mon 18 Mar 2019 04:10:39 PM UTC, comment #3: 

Rik. Could be different for windows. May make sense
to fix it in Linux first. John was going to work on it since
it is his code...

Michael Godfrey <godfrey>
Group Member
Mon 18 Mar 2019 04:07:17 PM UTC, comment #2: 

This bug is reported against MS Windows.  Bug #55029 is about a problem on Linux with the underlying glibc.  It might not be a true duplicate?

I know the underlying kbhit function is different on Windows than it is on Linux.

Rik <rik5>
Group administrator
Mon 18 Mar 2019 10:55:35 AM UTC, comment #1: 

This is an outstanding bug as reported in #55029.

Michael Godfrey <godfrey>
Group Member
Mon 18 Mar 2019 03:44:16 AM UTC, original submission:  

I just loaded Octave 5.1.0 into my windows 10 pc, after uninstalling the older version. Now pause does not work when there is no argument. Example


x=0:.5:10;
y1=sin(x)
pause;
y2=cos(x)


This simple script should show y1 and then it should suspend the program until a key is pressed. It simply does not, and it runs all the way through and stops after y2 is displayed.

I also tried variations, such as leaving off the ";" after the pause, or a blank argument: pause(). But if I include an argument:


x=0:.5:10;
y1=sin(x)
pause(5);
y2=cos(x)


Then it does work properly, pausing 5 seconds between showing y1 and y2.

This does not seem to be bug 52084. It is a much simpler situation, and it is new in 5.1.0, at least for my installation on windows 10. The pause worked fine on the version that I just uninstalled, and it fails on the new version.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #46662:  win-kbhit.diff added by mtmiller (568B - text/x-patch)

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by gennadii (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by pantxo
  • -email is unavailable- added by scivision (Posted a comment)
  • -email is unavailable- added by alans (Posted a comment)
  • -email is unavailable- added by dannp29 (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by godfrey (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 16 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-10-21 mtmiller Dependencies- bugs #57089 is dependent
    2019-06-03 philipnienhuis StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2019-05-29 pantxo StatusFixed Ready For Test
        Open/ClosedClosed Open
        Carbon-Copy- Added -email is unavailable-
    2019-04-12 rik5 StatusPatch Reviewed Fixed
        Open/ClosedOpen Closed
    2019-04-08 rik5 StatusPatch Submitted Patch Reviewed
    2019-03-29 mtmiller Attached File- Added win-kbhit.diff, #46662
        StatusConfirmed Patch Submitted
    2019-03-27 mtmiller CategoryNone Octave Function
        SummaryThe pause function fails when there is no argument pause() with no arguments returns immediately on Windows
    2019-03-18 philipnienhuis StatusNeed Info Confirmed
    2019-03-18 mtmiller StatusDuplicate Need Info
    2019-03-18 godfrey StatusNone Duplicate

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code