hgsave weirdness

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

hgsave weirdness

Dmitri A. Sergatskov
$ cat t2.m
h1=figure();
plot(randn(10));
fname = "t2.ofig"
hgsave(h1, fname)
h2=hgload(fname)
h1_l = get(h1);
h2_l = get(h2);
assert(h1, h2)


$ ls -l t2.ofig
ls: cannot access 't2.ofig': No such file or directory

octave:1> t2
fname = t2.ofig
error: hgload: unable to locate file t2.ofig
error: called from
    hgload at line 60 column 7
    t2 at line 5 column 3
octave:2> t2
fname = t2.ofig
h2 =  3
error: ASSERT errors for:  assert (h1,h2)

  Location  |  Observed  |  Expected  |  Reason
     ()           2            3         Abs err 1 exceeds tol 0 by 1
octave:3>

Adding pause(10) after hgsave() does not seem to change anything, so
it is not a timing issue.

What is going on here?

Dmitri.
--

Reply | Threaded
Open this post in threaded view
|

Re: hgsave weirdness

Rik-4
On 09/23/2019 09:00 AM, [hidden email] wrote:
Subject:
hgsave weirdness
From:
"Dmitri A. Sergatskov" [hidden email]
Date:
09/22/2019 09:27 PM
To:
Octave Help [hidden email], octave-maintainers [hidden email]
List-Post:
[hidden email]
Precedence:
list
MIME-Version:
1.0
Message-ID:
[hidden email]
Content-Type:
text/plain; charset="UTF-8"
Message:
2

$ cat t2.m
h1=figure();
plot(randn(10));
fname = "t2.ofig"
hgsave(h1, fname)
h2=hgload(fname)
h1_l = get(h1);
h2_l = get(h2);
assert(h1, h2)


$ ls -l t2.ofig
ls: cannot access 't2.ofig': No such file or directory

octave:1> t2
fname = t2.ofig
error: hgload: unable to locate file t2.ofig
error: called from
    hgload at line 60 column 7
    t2 at line 5 column 3
octave:2> t2
fname = t2.ofig
h2 =  3
error: ASSERT errors for:  assert (h1,h2)

  Location  |  Observed  |  Expected  |  Reason
     ()           2            3         Abs err 1 exceeds tol 0 by 1
octave:3>

Adding pause(10) after hgsave() does not seem to change anything, so
it is not a timing issue.

What is going on here?

I'm not seeing the first problem with hgload.  Here is my session

~/wip/Projects_Mine/octave-dev: run-octave --no-gui-libs -f -q
octave:1> t2
fname = t2.ofig
h2 =  2
error: ASSERT errors for:  assert (h1,h2)

  Location  |  Observed  |  Expected  |  Reason
     ()           1            2         Abs err 1 exceeds tol 0 by 1

I started Octave with -f to make sure there was no user configuration issues that might be a problem.

The reason why h1 != h2 is that the original figure was not closed after hgsave.  When you do hgload, it would like to use the next available figure handle which can't be '1' in this case so Octave uses '2'.  If I add "close (h1)" after hgsave then the script runs with no errors.

--Rik


      

Reply | Threaded
Open this post in threaded view
|

Re: hgsave weirdness

Dmitri A. Sergatskov


On Mon, Sep 23, 2019 at 12:31 PM Rik <[hidden email]> wrote:
On 09/23/2019 09:00 AM, [hidden email] wrote:
Subject:
hgsave weirdness
From:
"Dmitri A. Sergatskov" [hidden email]
Date:
09/22/2019 09:27 PM
To:
Octave Help [hidden email], octave-maintainers [hidden email]
List-Post:
[hidden email]
Precedence:
list
MIME-Version:
1.0
Message-ID:
[hidden email]
Content-Type:
text/plain; charset="UTF-8"
Message:
2

$ cat t2.m
h1=figure();
plot(randn(10));
fname = "t2.ofig"
hgsave(h1, fname)
h2=hgload(fname)
h1_l = get(h1);
h2_l = get(h2);
assert(h1, h2)


$ ls -l t2.ofig
ls: cannot access 't2.ofig': No such file or directory

octave:1> t2
fname = t2.ofig
error: hgload: unable to locate file t2.ofig
error: called from
    hgload at line 60 column 7
    t2 at line 5 column 3
octave:2> t2
fname = t2.ofig
h2 =  3
error: ASSERT errors for:  assert (h1,h2)

  Location  |  Observed  |  Expected  |  Reason
     ()           2            3         Abs err 1 exceeds tol 0 by 1
octave:3>

Adding pause(10) after hgsave() does not seem to change anything, so
it is not a timing issue.

What is going on here?

I'm not seeing the first problem with hgload.  Here is my session

~/wip/Projects_Mine/octave-dev: run-octave --no-gui-libs -f -q
octave:1> t2
fname = t2.ofig
h2 =  2
error: ASSERT errors for:  assert (h1,h2)

  Location  |  Observed  |  Expected  |  Reason
     ()           1            2         Abs err 1 exceeds tol 0 by 1

I started Octave with -f to make sure there was no user configuration issues that might be a problem.

The reason why h1 != h2 is that the original figure was not closed after hgsave.  When you do hgload, it would like to use the next available figure handle which can't be '1' in this case so Octave uses '2'.  If I add "close (h1)" after hgsave then the script runs with no errors.


assert() here is irrelevant (it is leftover from other tests, and it should have been assert (h1_l, h2_l).
I am puzzled why hgload does not see the file. I wonder if hgsave forgets to fclose it or something like that.

Dmitri.
--

Reply | Threaded
Open this post in threaded view
|

Re: hgsave weirdness

Dmitri A. Sergatskov


On Mon, Sep 23, 2019 at 12:45 PM Dmitri A. Sergatskov <[hidden email]> wrote:


On Mon, Sep 23, 2019 at 12:31 PM Rik <[hidden email]> wrote:
On 09/23/2019 09:00 AM, [hidden email] wrote:
Subject:
hgsave weirdness
From:
"Dmitri A. Sergatskov" [hidden email]
Date:
09/22/2019 09:27 PM
To:
Octave Help [hidden email], octave-maintainers [hidden email]
List-Post:
[hidden email]
Precedence:
list
MIME-Version:
1.0
Message-ID:
[hidden email]
Content-Type:
text/plain; charset="UTF-8"
Message:
2

$ cat t2.m
h1=figure();
plot(randn(10));
fname = "t2.ofig"
hgsave(h1, fname)
h2=hgload(fname)
h1_l = get(h1);
h2_l = get(h2);
assert(h1, h2)


$ ls -l t2.ofig
ls: cannot access 't2.ofig': No such file or directory

octave:1> t2
fname = t2.ofig
error: hgload: unable to locate file t2.ofig
error: called from
    hgload at line 60 column 7
    t2 at line 5 column 3
octave:2> t2
fname = t2.ofig
h2 =  3
error: ASSERT errors for:  assert (h1,h2)

  Location  |  Observed  |  Expected  |  Reason
     ()           2            3         Abs err 1 exceeds tol 0 by 1
octave:3>

Adding pause(10) after hgsave() does not seem to change anything, so
it is not a timing issue.

What is going on here?

I'm not seeing the first problem with hgload.  Here is my session



So I added pause(10) after hgsave and also changed hgsave to text format.
During those 10 seconds delay i run less t2.ofig and see that the file is there.

I also ran strace on this but all I see is:

<...>
read(5, "\4\0\0\0\0\0\0\0", 16)         = 8
recvmsg(11, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(11, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=11, events=POLLIN}, {fd=12, events=POLLIN}, {fd=14, events=POLLIN}], 4, 8145) = 0 (Timeout)
recvmsg(11, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(11, {msg_namelen=0}, 0)         = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=5, events=POLLIN}, {fd=11, events=POLLIN}, {fd=12, events=POLLIN}, {fd=14, events=POLLIN}], 4, 19864error: hgload: unable to locate file t2.ofig
error: called from
    hgload at line 60 column 7
    t2 at line 6 column 3
) = 1 ([{fd=5, revents=POLLIN}])
read(5, "\1\0\0\0\0\0\0\0", 16)         = 8
<...>
This is repeatable 100% on 2 different computers with Fedora 31. I will try clang compile next.

Dmitri.
--


Reply | Threaded
Open this post in threaded view
|

Re: hgsave weirdness

Dmitri A. Sergatskov


On Mon, Sep 23, 2019 at 1:14 PM Dmitri A. Sergatskov <[hidden email]> wrote:


This is repeatable 100% on 2 different computers with Fedora 31. I will try clang compile next.

And clang compile has the same problem.


Dmitri.
--
Reply | Threaded
Open this post in threaded view
|

Re: hgsave weirdness

Rik-4
On 09/23/2019 11:46 AM, Dmitri A. Sergatskov wrote:
> > > On Mon, Sep 23, 2019 at 1:14 PM Dmitri A. Sergatskov [hidden email] wrote: > > > > This is repeatable 100% on 2 different computers with Fedora 31. I will try clang compile next. > > > And clang compile has the same problem. >
Try the debugger.

debug_on_error (1)
t2

According to the backtrace published earlier,

error: hgload: unable to locate file t2.ofig
error: called from
    hgload at line 60 column 7
    t2 at line 5 column 3

the problem is in hgload at line 60.  If I look at that code, I see

if (isempty (file_in_loadpath (filename)))
  error ("hgload: unable to locate file %s", filename);
endif

So, I would start with the debugger and when you reach line 60 take a look at your path variable.  Maybe something is removing '.' from the search path (.octaverc configuration file?).

--Rik

Reply | Threaded
Open this post in threaded view
|

Re: hgsave weirdness

Dmitri A. Sergatskov
On Mon, Sep 23, 2019 at 2:00 PM Rik <[hidden email]> wrote:

>
> error: hgload: unable to locate file t2.ofig
> error: called from
>     hgload at line 60 column 7
>     t2 at line 5 column 3
>
> the problem is in hgload at line 60.  If I look at that code, I see
>
> if (isempty (file_in_loadpath (filename)))
>   error ("hgload: unable to locate file %s", filename);
> endif
>
> So, I would start with the debugger and when you reach line 60 take a look at your path variable.  Maybe something is removing '.' from the search path (.octaverc configuration file?).

I tried and "." is the very first in path.
It works also if I run it it immediately the second time.

Also:

octave:1> t2
fname = t2.ofig
error: hgload: unable to locate file t2.ofig
error: called from
    hgload at line 60 column 7
    t2 at line 6 column 3
octave:2> file_in_loadpath ("t2.ofig")
ans = /d2/home/dima/src/octave/clang/t2.ofig

But it is something with loadpath. If I change fname to /tmp/t2.ofig it works.


>
> --Rik
>

Dmitri.
--

Reply | Threaded
Open this post in threaded view
|

Re: hgsave weirdness

Dmitri A. Sergatskov
Here is t2.m:

$ cat t2.m
h1=figure();
plot(randn(10));
fname = "t2.ofig"
hgsave(h1, fname, '-text')
pause(10)
file_in_loadpath("octave-config.h")
file_in_loadpath(fname)
glob(fname)
h2=hgload(fname)
h1_l = get(h1);
h2_l = get(h2);
assert(h1_l, h2_l)

$ ./run-octave -f -q
octave:1> t2
fname = t2.ofig
ans = /d2/home/dima/src/octave/clang/octave-config.h
ans =
ans =
{
  [1,1] = t2.ofig
}

error: hgload: unable to locate file t2.ofig
error: called from
    hgload at line 60 column 7
    t2 at line 9 column 3
octave:2> t2                                      ## !!! just re-run it
fname = t2.ofig
ans = /d2/home/dima/src/octave/clang/octave-config.h
ans = /d2/home/dima/src/octave/clang/t2.ofig
ans =
{
  [1,1] = t2.ofig
}

h2 =  3
error: ASSERT errors for:  assert (cond {i},expected {i},tol)

  Location  |  Observed  |  Expected  |  Reason
     ()        -80.6879    -127.3832     Abs err 46.695 exceeds tol 0 by 5e+01

ASSERT errors for:  assert (cond {i},expected {i},tol)

  Location  |  Observed  |  Expected  |  Reason
     ()        -80.6879    -127.3832     Abs err 46.695 exceeds tol 0 by 5e+01

ASSERT errors for:  assert (cond {i},expected {i},tol)

  Location  |  Observed  |  Expected  |  Reason
     ()           2            3         Abs err 1 exceeds tol 0 by 1

ASSERT errors for:  assert (cond {i},expected {i},tol)

  Location  |  Observed  |  Expected  |  Reason
    (1)           1            -1        Abs err 2 exceeds tol 0 by 2
    (2)          757           -1        Abs err 758 exceeds tol 0 by 8e+02
    (3)          560           -1        Abs err 561 exceeds tol 0 by 6e+02
    (4)          444           -1        Abs err 445 exceeds tol 0 by 4e+02

ASSERT errors for:  assert (cond {i},expected {i},tol)

  Location  |  Observed  |  Expected  |  Reason
    (1)          0.25        1.3368      Abs err 1.0868 exceeds tol 0 by 1
    (2)          2.5         3.3151      Abs err 0.81513 exceeds tol 0 by 0.8
    (3)           8          5.8263      Abs err 2.1737 exceeds tol 0 by 2
    (4)           6          4.3697      Abs err 1.6303 exceeds tol 0 by 2
octave:3>


????

Dmitri.
--

Reply | Threaded
Open this post in threaded view
|

Re: hgsave weirdness

John W. Eaton
Administrator
In reply to this post by Dmitri A. Sergatskov
On 9/23/19 3:11 PM, Dmitri A. Sergatskov wrote:

> On Mon, Sep 23, 2019 at 2:00 PM Rik <[hidden email]> wrote:
>
>>
>> error: hgload: unable to locate file t2.ofig
>> error: called from
>>      hgload at line 60 column 7
>>      t2 at line 5 column 3
>>
>> the problem is in hgload at line 60.  If I look at that code, I see
>>
>> if (isempty (file_in_loadpath (filename)))
>>    error ("hgload: unable to locate file %s", filename);
>> endif
>>
>> So, I would start with the debugger and when you reach line 60 take a look at your path variable.  Maybe something is removing '.' from the search path (.octaverc configuration file?).
>
> I tried and "." is the very first in path.
> It works also if I run it it immediately the second time.
>
> Also:
>
> octave:1> t2
> fname = t2.ofig
> error: hgload: unable to locate file t2.ofig
> error: called from
>      hgload at line 60 column 7
>      t2 at line 6 column 3
> octave:2> file_in_loadpath ("t2.ofig")
> ans = /d2/home/dima/src/octave/clang/t2.ofig
>
> But it is something with loadpath. If I change fname to /tmp/t2.ofig it works.

Yes, the bug appears to be in file_in_loadpath.  If I make the following
change in hgload.m, it will loop forever.  But stat shows that the file
exists and I can see it with ls in a command window while Octave is looping.

diff --git a/scripts/plot/util/hgload.m b/scripts/plot/util/hgload.m
--- a/scripts/plot/util/hgload.m
+++ b/scripts/plot/util/hgload.m
@@ -56,9 +56,13 @@ function [h, old_prop] = hgload (filenam
        error ("hgload: unable to locate file %s", filename);
      endif
    else
-    if (isempty (file_in_loadpath (filename)))
-      error ("hgload: unable to locate file %s", filename);
-    endif
+    ii = 0;
+    while (isempty (file_in_loadpath (filename)))
+      stat (filename)
+      ii++
+      pause (1);
+    endwhile
+    ii
    endif

    ## Load the handle structure


I'm guessing a loadpath caching error for filenames that are not absolute?

Trying older versions, it looks like it first started failing in 4.2.x.

jwe