bugGNU Octave - Bugs: bug #53354, print() with ampersand (&) in...

 
 

bug #53354: print() with ampersand (&) in path or name crash (windows 64)

Submitter:  Gregory White <gwhite>
Submitted:  Thu 15 Mar 2018 10:37:06 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Confirmed Assigned to:  None
Originator Name:  Gregory White Open/Closed:  * Open
Release:  * 4.2.2 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 27 Apr 2018 07:26:44 PM UTC, comment #10: 

I have the same issue with spaces in folder name. After some debugging, I found that command line which calls GS is not correct. In my case it is

cmd = C:\Octave\OCTAVE~1.2\bin\gs.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -dAutoRotatePages=/None -sDEVICE=eps2write -sOutputFile=""test test\test.eps"" -

As you can see, there are two double quotes in output file name.

Variable 'fileout' in line 607 of print.m gets extra single quotes, which in line 688 are replaced with double quotes. Additional quotes are added in line 148 of _ghostscript_.m.

Removing the extra quotes in _ghostscript_.m resolves the issue.


Oleg Mouraenko <omouraenko>
Tue 20 Mar 2018 11:28:51 PM UTC, comment #9: 


> A. Use a temporary file name when calling gl2ps irrespective to name being problematic or not
> B. Rename temporary file name to original filename.


Ah! I did not consider the case of  problematic directory name.

A. Use a temporary file name when calling gl2ps irrespective to name being problematic or not

B. mv temporary file to directory with change filename to original one.

Tatsuro MATSUOKA <tmacchant>
Tue 20 Mar 2018 11:02:16 PM UTC, comment #8: 


> A solution can be
> 1. Identify file name with problematic characters.
> 2. In case of problematic file:
> A. Use a temporary file name when calling gl2ps
> B. Copy this file to the original name
> C. Delete the temporary file


I think that process can be simpilfied to

A. Use a temporary file name when calling gl2ps irrespective to name being  problematic or not
B. Rename temporary file name to original filename.

Tatsuro MATSUOKA <tmacchant>
Tue 20 Mar 2018 07:17:30 PM UTC, comment #7: 

A solution can be
1. Identify file name with problematic characters.
2. In case of problematic file:
   A. Use a temporary file name when calling gl2ps
   B. Copy this file to the original name
   C. Delete the temporary file

what do you think?

Avinoam Kalma <avinoam>
Group Member
Sat 17 Mar 2018 05:25:05 PM UTC, comment #6: 

@Avinoam: Thanks, this is good news.

Pantxo Diribarne <pantxo>
Group Member
Sat 17 Mar 2018 01:48:38 PM UTC, comment #5: 

@Pantxo: I can't build current version, but using hg_id 170e8625562a (http://hg.savannah.gnu.org/hgweb/octave/rev/170e8625562a)

I get:


>> plot(0:1,0:1),print("C:/V&V/test.eps",'-depsc')
GL2PS warning: Unknown token in buffer
GPL Ghostscript 9.16: **** Could not open the file C:/V .
**** Unable to open the initial device, quitting.
'V' is not recognized as an internal or external command,
operable program or batch file.
error: gl2ps_renderer::draw: internal pipe error
>> error: parse error
error: called from
    __opengl_print__ at line 158 column 7
    print at line 555 column 14


Indeed, the crash issue was fixed.

Avinoam Kalma <avinoam>
Group Member
Fri 16 Mar 2018 09:35:46 AM UTC, comment #4: 

@Avinoam: we should split this into two main issues:

  • Octave crashes when something goes wrong during the execution of a piped command: I hope this one is fixed in the current stable branch (to become Octave 4.4).
  • Some characters that are valid in a Windows path (like &, SPACE, (), ...) are not handled correctly when present in a  piped command.


It would help much if someone could verify that the first point is "fixed" (error instead of crash) in stable.

Pantxo Diribarne <pantxo>
Group Member
Fri 16 Mar 2018 08:58:17 AM UTC, comment #3: 

Running in octave-cli:


octave:5> print("C:/V&V/test.eps",'-depsc')
'V' is not recognized as an internal or external command,
operable program or batch file.
error: gl2ps_renderer::draw: internal pipe error
terminate called after throwing an instance of 'octave::execution_exception'

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
panic: Aborted -- stopping myself...
attempting to save variables to 'octave-workspace'...
save to 'octave-workspace' complete


Avinoam Kalma <avinoam>
Group Member
Fri 16 Mar 2018 08:53:51 AM UTC, comment #2: 

Hi,

I think this is more or less a duplicate of bug #49718.

@Tatsuro: could you test with the current stable (which will become 4.4) and see if there is still a crash or simply an error?

Pantxo Diribarne <pantxo>
Group Member
Fri 16 Mar 2018 07:26:34 AM UTC, comment #1: 

Reproduced in octave-4.2.2 (64 bit) on windows 10.
I cannot use C:\ due to permission, I have tested on Drive D:

Tatsuro MATSUOKA <tmacchant>
Thu 15 Mar 2018 10:37:06 PM UTC, original submission:  

The "&" symbol is valid in Windows (w7_64) for filenames or paths. It seems to cause a crash with the print command:


plot(0:1,0:1),print("C:/test.eps",'-depsc')     %Octave does not crash/close
plot(0:1,0:1),print("C:/V&V/test.eps",'-depsc') % Octave does crash/close
plot(0:1,0:1),print("C:/V&Vtest.eps",'-depsc')  % Octave does crash /close


It doesn't seem to tolerate the "&" symbol in the filename or the path. I did some looking to see if an escape was needed for &, but did not find anything.

This works fine, btw:

addpath("C:/V&V/")


Also, a SAVE AS with the figure window allows a PDF save to a folder including &.

>> version

ans = 4.2.2

Gregory White <gwhite>

 

(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 omouraenko (Posted a comment)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by avinoam (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by tmacchant (Posted a comment)
  • -email is unavailable- added by gwhite (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-03-17 pantxo Item GroupOther Unexpected Error or Warning
    2018-03-17 mtmiller Release4.2.1 4.2.2
    2018-03-16 pantxo StatusNone Confirmed
        Releaseother 4.2.1

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code