bugGNU Octave - Bugs: bug #49219, hang in imread for non-exiting...

 
 

bug #49219: hang in imread for non-exiting filename with spaces

Submitter:  None
Submitted:  Wed 28 Sep 2016 09:04:20 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Works For Me Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 29 Sep 2016 11:01:09 PM UTC, comment #12: 

I made the change to filenames without spaces in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/1751d490dc2f).  We want to be testing Octave, not accidentally testing the DNS configuration of the host machine.

Rik <rik5>
Group administrator
Thu 29 Sep 2016 09:19:40 PM UTC, comment #11: 

I agree this is a DNS or proxy issue.
curl of a regular URL does work on my system.

In the mean time this patch helps to run make check to completion.


diff -r ead11c8bd701 scripts/image/imfinfo.m
--- a/scripts/image/imfinfo.m   Wed Sep 28 15:13:02 2016 -0400
+++ b/scripts/image/imfinfo.m   Thu Sep 29 23:13:45 2016 +0200
@@ -173,7 +173,7 @@
 %! imformats ("update", "jpg", fmt);
 %! unwind_protect
 %!   try
-%!     imread ("I sure hope this file does not exist.jpg");
+%!     imread ("I_sure_hope_this_file_does_not_exist.jpg");
 %!   catch
 %!     error_thrown = true;
 %!   end_try_catch
diff -r ead11c8bd701 scripts/image/imread.m
--- a/scripts/image/imread.m    Wed Sep 28 15:13:02 2016 -0400
+++ b/scripts/image/imread.m    Thu Sep 29 23:13:45 2016 +0200
@@ -171,7 +171,7 @@
 %! imformats ("update", "jpg", fmt);
 %! unwind_protect
 %!   try
-%!     imread ("I sure hope this file does not exist.jpg");
+%!     imread ("I_sure_hope_this_file_does_not_exist.jpg");
 %!   catch
 %!     error_thrown = true;
 %!   end_try_catch


Anonymous
Thu 29 Sep 2016 09:07:45 PM UTC, comment #10: 

I just filed bug #49228 about whether non-existent files should be treated as URLs always, or only if they actually look like fully-qualified URLs.

Mike Miller <mtmiller>
Group Member
Thu 29 Sep 2016 08:33:04 PM UTC, comment #9: 

Yeah, I've spun up an old Ubuntu 12.04 with curl 7.22 and I don't get a hang with "curl 'one two.txt'", it doesn't seem to be something that just used to work and was fixed either.

Btw, for local files instead of host names, use


$ curl "file:one two.txt"
This is a local file
$ cat "one two.txt"
This is a local file


Actually now that I think of it, since it's trying to resolve the name as a host, it might be a problem in your resolver or your local DNS configuration.

Anyway, this is the way that imread is meant to work, if the file doesn't exist on the local filesystem it tries to load it as a URL. If that is taking forever to resolve with your configuration, that's probably a DNS or network-related problem.

Mike Miller <mtmiller>
Group Member
Thu 29 Sep 2016 08:25:35 PM UTC, comment #8: 

I tried on the command line and I get


curl 'xx 1.jpg'
curl: (6) Could not resolve host: xx 1.jpg


There must be something odd with your local machine's configuration.

In any case, this doesn't appear to be an Octave problem so I'm going to close the report.

Rik <rik5>
Group administrator
Thu 29 Sep 2016 07:32:59 PM UTC, comment #7: 

so I upgraded my curl to 7.50.3.
To no avail. Still a hang on curl 'xx 1.jpg', but not on xx1.jpg

Anonymous
Thu 29 Sep 2016 07:22:56 PM UTC, comment #6: 

will hang in [a,b,c] = urlwrite ('xx 1.jpg', 'urltmp.txt')

the command line version will hang too with a space:
curl 'xx 1.jpg'

curl xx1.jpg returns right away.
So this seems to be a curl issue.

Anonymous
Thu 29 Sep 2016 06:48:43 PM UTC, comment #5: 

My version of the curl library is certainly newer (7.43.0).

Can you try the following urlwrite code at an Octave prompt and see what happens?


[a,b,c] = urlwrite ('xx 1.jpg', 'urltmp.txt')
[d,~] = urlwrite ('xx 2.jpg', 'urltmp2.txt')



Rik <rik5>
Group administrator
Thu 29 Sep 2016 06:03:14 PM UTC, comment #4: 

./run-octave -x show it hangs in urlwrite (called in imageIO line 64)


+ if (isempty (fn) && !isempty (varargin))
+   ## Maybe if we add a file extension
+   fn = abs_path ([filename, ".", varargin{1}]);
+ endif
+ ## Maybe we have an URL
+ if (isempty (fn))
+   file_2_delete = true;
+   ## mark file for deletion
+   [fn, ~] = urlwrite (filename, tempname ());
+   ## Maybe the URL is missing the file extension
+   if (isempty (fn) && !isempty (varargin))
+     [fn, ~] = urlwrite ([filename, ".", varargin{1}], tempname ());
+   endif
+   if (isempty (fn))
+     error ("%s: unable to find file %s", func, filename);
+   endif
+ endif
+ file_2_delete = true;
+ ## mark file for deletion
+ [fn, ~] = urlwrite (filename, tempname ());


curl version is 7.29.0

Anonymous
Thu 29 Sep 2016 05:12:49 PM UTC, comment #3: 

Also not able to reproduce here (with GM 1.3.25).

If this is reproducible for you, can you provide a gdb backtrace of what Octave is doing when it looks like it's hanging?

Mike Miller <mtmiller>
Group Member
Thu 29 Sep 2016 06:15:16 AM UTC, comment #2: 

Works from me also with 4.2.0-rc2 on Win-7


>> bug49219
attempting imread xx_1.jpg
file xx_1.jpg does not exist
attempting imread xx 1.jpg
file xx 1.jpg does not exist
Elapsed time is 1.21012 seconds.
Elapsed time is 6.77068 seconds.


Note that the second time takes 5.5 more.
If I switch the names, the time takes 5.5 more.

Avinoam Kalma <avinoam>
Group Member
Thu 29 Sep 2016 02:49:28 AM UTC, comment #1: 

This works for me.

gcc 5.2.1, GraphicsMagick 1.3.21, Ubuntu 15.10

Rik <rik5>
Group administrator
Wed 28 Sep 2016 09:04:20 PM UTC, original submission:  

on my system make check hangs on scripts/image/imfinfo test.
This can be reduced to this script


names = {'xx_1.jpg', 'xx 1.jpg'};
for i = 1 : length(names)
   try
     fprintf(2, 'attempting imread %s\n', names{i});
     imread (names{i});
   catch
     fprintf(2, 'file %s does not exist\n', names{i});
     error_thrown = true;
   end_try_catch
end


which produces


attempting imread xx_1.jpg
file xx_1.jpg does not exist
attempting imread xx 1.jpg


and hangs (also on 4.0.3) in the imread 'xx 1.jpg'.
gcc 4.9.3, GraphicMagick 1.3.17, RHEL 6.8

Anonymous

 

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

    Date Changed by Updated Field Previous Value => Replaced by
    2016-09-29 rik5 Open/ClosedOpen Closed
    2016-09-29 rik5 StatusNone Works For Me

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code