Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#6213 closed defect (fixed)

gdaldem_lib.cpp does not report error correctly

Reported by: Ari Jolma Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

Running DEMProcessing with 'hillshade' and '/vsistdout' results in

Unable to create dataset /vsistdout 4
Unable to create dataset /vsistdout 4

which is coming from gdaldem_lib.cpp:2613. The second line should be

Attempt to create new tiff file `/vsistdout' failed: No such file or directory

I even tried setting CPL_ACCUM_ERROR_MSG to ON but it did not have any effect.

Change History (4)

comment:1 by Ari Jolma, 8 years ago

And, BTW, how can I use the GTiff driver. I seems that I need to set some creation options, which I can't actually do. Well, anyway I can use PNG.

comment:2 by Even Rouault, 8 years ago

Resolution: fixed
Status: newclosed

The correct name is /vsistdout/ with trailing slash. I've verified that it works once you use it. No explicit option needed. I've fixed gdaldem_lib to not re-emit the previous error message (r31423) CPL_ACCUM_ERROR_MSG=ON doesn't work with the default handler as far as I can see, but only if you install a custom error handler (which makes sense).

comment:3 by Ari Jolma, 8 years ago

Actually the 2nd error message does say it: "No such file or directory", i.e., "/vsistdout" is not a valid name.

comment:4 by Ari Jolma, 8 years ago

Actually the issue is much more complex. I was wondering why it worked with PNG driver with both /vsistdout and /vsistdout/. With GTiff the driver specifically detects /vsistdout/ and goes into streaming mode. With /vsistdout it goes to the normal mode.

The difference is that PNG driver opens with flags wb and GTiff with w+b and '+' is not supported by /vsistdout. That creates an error message "Read or update mode not supported on /vsistdout" in cpl_vsil_stdout.cpp but it is overridden with error message "Attempt to create new tiff file `/vsistdout' failed: No such file or directory" at geotiff.cpp, which is then overridden with error message from gdaldem_lib.cpp.

I think I'm going to install by default an accumulating error message handler into the Perl bindings.

Maybe there is not a bug but it sure is a bit confusing. Maybe the use of "/vsistdout" should be somehow deprecated over "/vsistdout/" (with a warning message, as it is the correct name as you write) as it now works in some cases. Also the error message generated at geotiff.cpp is in fact incorrect as it is CPLE_NotSupported and not CPLE_OpenFailed - at least the string coming from CPLE_OpenFailed is incorrect.

Note: See TracTickets for help on using tickets.