Fix uninformative hp2ps error when the cmdline contains double quotes
Concern Raised390df8b51b91

Authored by watashi on Nov 22 2018, 10:51 AM.


Fix uninformative hp2ps error when the cmdline contains double quotes

The format of hp file didn't allow double quotes inside strings, and
under prof build, we include args in JOB, which may have double quotes.
When this happens, the error message is confusing to the user. This can
also happen under normal build if the executable name contains double
quite, which is unlikely though.

We fix this issue by introducing escaping for double quotes inside a
string by repeating it twice.

We also fix a buffer overflow bug when the length of the string happen
to be multiple of 5000.

Test Plan:
new tests, which used to fail with error message:

hp2ps: "T15904".hp, line 2: integer must follow identifier

use new ghc and hp2ps to profile a simple program.

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: Trac #15904

Differential Revision:

bgamari raised a concern with this commit.Nov 24 2018, 12:47 PM
bgamari added a subscriber: bgamari.

I am seeing this fail locally with

=====> T15904(normal) 1 of 1 [0, 0, 0]
cd "hp2ps/" && $MAKE -s --no-print-directory T15904  
Actual stdout output differs from expected:
diff -uw "hp2ps/" "hp2ps/"
--- hp2ps/	2018-11-24 13:43:02.425260912 -0500
+++ hp2ps/	2018-11-24 13:43:02.425260912 -0500
@@ -1,6 +1,5 @@
 [1 of 1] Compiling T15904           ( T15904.hs, T15904.o )
 Linking "T15904" ...
 {"e": 2.72, "pi": 3.14}

I am going to revert for the time being. Do you think you could have a look, @watashi?

This commit now has outstanding concerns.Nov 24 2018, 12:47 PM

@bgamari do you mind provide the shell version info you are using for test? It seems to be imcompatibity of $ā€™\nā€™. I will remove it from the test case.