bugGNU Octave - Bugs: bug #45914, fopen warns "found by...

 
 

bug #45914: fopen warns "found by searching load path" although the file doesn't exist

Submitter:  Andreas Weber <andy1978>
Submitted:  Thu 10 Sep 2015 06:57:44 AM UTC
   
 
Category:  Interpreter Severity:  2 - Minor
Priority:  3 - Low Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 15 Aug 2018 04:39:11 PM UTC, comment #3: 

Lowering the priority.  This is mostly a nuisance.  The suggestion by jwe to search the cache first, but then verify the result, would work.  However, at that point one is presumably calling stat() on the file.  Wouldn't it be simpler to do away with the cache itself then since regardless of hit you would need to call stat?  That would be a big step and I'm not really proposing to do it, but it does seem like a lot of advantages would be lost.

Rik <rik5>
Group administrator
Fri 11 Sep 2015 02:24:36 PM UTC, comment #2: 

I think the problem is that info about directories in teh load path is cached and the cache is updated when Octave issues a prompt and also when a few other events happen, like adding a new directory to the path.  The case of removing a file from a directory in the path hasn't been handled.

But even if we fix unlink to refresh the cached load path info when removing a file from a directory that is in the load path, we could still have problems with other things like


  system ("rm -f /tmp/x")


and there's really no way to know.

So maybe a better approach would just be to first look in the cache for files (for speed) and then verify that the file found from the cache actually does exist before returning success?

John W. Eaton <jwe>
Group administrator
Fri 11 Sep 2015 02:20:24 AM UTC, comment #1: 

Confirmed on the default branch here also.

Not so much about timing, this also shows the same error:


>> x = 0;
>> save x x
>> unlink ("x"); sleep (10); fd = fopen ("x", "rb")
warning: fopen: '/tmp/x' found by searching load path
fd = -1


Mike Miller <mtmiller>
Group Member
Thu 10 Sep 2015 06:57:44 AM UTC, original submission:  

This looks like some timing problem. Run this in the CLI


fn = "foo.log";
save (fn, "fn");


and then paste to CLI in one line OR create a script file and run it (it will not show the warning if unlink and fopen are run separately)


>> unlink (fn); fid = fopen (fn, 'rb')
warning: fopen: '/home/andy/temp/foo.log' found by searching load path
fid = -1


Andreas Weber <andy1978>
Group Member

 

(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 rik5 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by andy1978 (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-08-15 rik5 Priority5 - Normal 3 - Low
        Item GroupNone Incorrect Result
    2015-09-11 mtmiller CategoryNone Interpreter
        StatusNone Confirmed
        Release4.0.0 dev

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code