Bug 1526703 - xen FTBFS (ocaml)
Summary: xen FTBFS (ocaml)
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: xen
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Michael Young
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-12-16 13:05 UTC by Michael Young
Modified: 2018-02-07 21:12 UTC (History)
4 users (show)

Fixed In Version: xen-4.10.0-1.fc28
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-07 21:12:24 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
xen-safe-strings.patch (3.13 KB, text/plain)
2017-12-16 23:29 UTC, Richard W.M. Jones
no flags Details

Description Michael Young 2017-12-16 13:05:06 UTC
One of the build problems for xen on Fedora 28 is an ocaml issue due to the string changes in OCaml 4.06

The error is
make[8]: Entering directory '/builddir/build/BUILD/xen-4.9.1/tools/ocaml/libs/xc'
 MLDEP    
 MLI      xenctrl.cmi
 MLC      xenctrl.cmo
File "xenctrl.ml", line 268, characters 44-45:
Error: This expression has type bytes but an expression was expected of type
         string

(from the scratch build logs in https://koji.fedoraproject.org/koji/taskinfo?taskID=23655433 )

The source file is at http://xenbits.xenproject.org/gitweb/?p=xen.git;a=blob;f=tools/ocaml/libs/xc/xenctrl.ml;h=75006e711cbe09354b699add364c584412e84b46;hb=ae34ab8c5d2e977f6d8081c2ce4494875232f563

Comment 1 Richard W.M. Jones 2017-12-16 13:20:33 UTC
I can't get past a bunch of other errors when building locally:

make[2]: Entering directory '/home/rjones/d/fedora/xen/master/xen-4.9.1/xen'
gcc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -Wp,-MD,tools/kconfig/.conf.o.d    -D_GNU_SOURCE -D_DEFAULT_SOURCE  -DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1 -DLOCALE -DKBUILD_NO_NLS  -c -o tools/kconfig/conf.o tools/kconfig/conf.c
tools/kconfig/conf.c: In function 'check_stdin':
tools/kconfig/conf.c:77:3: error: format not a string literal and no format arguments [-Werror=format-security]
   printf(_("aborted!\n\n"));
   ^~~~~~
tools/kconfig/conf.c:78:3: error: format not a string literal and no format arguments [-Werror=format-security]
   printf(_("Console input/output is redirected. "));
   ^~~~~~
tools/kconfig/conf.c:79:3: error: format not a string literal and no format arguments [-Werror=format-security]
   printf(_("Run 'make oldconfig' to update configuration.\n\n"));
   ^~~~~~
tools/kconfig/conf.c: In function 'conf_askvalue':
tools/kconfig/conf.c:89:3: error: format not a string literal and no format arguments [-Werror=format-security]
   printf(_("(NEW) "));
   ^~~~~~
tools/kconfig/conf.c: In function 'conf_choice':
tools/kconfig/conf.c:290:5: error: format not a string literal and no format arguments [-Werror=format-security]
     printf(_(" (NEW)"));
     ^~~~~~
tools/kconfig/conf.c: In function 'check_conf':
tools/kconfig/conf.c:438:6: error: format not a string literal and no format arguments [-Werror=format-security]
      printf(_("*\n* Restart config...\n*\n"));
      ^~~~~~

Comment 2 Richard W.M. Jones 2017-12-16 13:22:00 UTC
... ie. bug 1520038

Comment 3 Richard W.M. Jones 2017-12-16 13:26:02 UTC
This patch will probably fix the immediate OCaml problem but I'm sure you'll
find there are similar corrections that need to be made later in the
build as well.  Without being able to do a full build locally I cannot
come up with a proper patch.  Also did you check out upstream to see if
they have fixed this?  Most OCaml projects have been proactive in making
safe-string fixes already since the compiler change was first made in 2014.

 let coredump xch domid fd =
         let dump s =
-                let wd = Unix.write fd s 0 (String.length s) in
+                let wd = Unix.write fd (Bytes.of_string s) 0 (String.length s) in
                 if wd <> String.length s then
                         failwith "error while writing";
                 in

Comment 4 Michael Young 2017-12-16 20:22:41 UTC
For testing you could try the cut down build at https://copr-be.cloud.fedoraproject.org/results/myoung/xentest/fedora-rawhide-x86_64/00688379-xen/xen-4.10.0-0.3.fc28.src.rpm which is based on an update to xen-4.10.0 which I am intending to put into rawhide when I can get it to build. I think this matches the latest upstream state of xen's ocaml, and I don't think it differs much from xen-4.9.1. It includes some ocaml fixes in the xen.ocaml406.patch patch, but I am currently stuck on how to fix the error
File "logging.ml", line 63, characters 17-30:
Warning 3: deprecated: Stdext.String.create
Use Bytes.create instead.
File "logging.ml", line 65, characters 2-25:
Warning 3: deprecated: Stdext.String.set
Use Bytes.set instead.
File "logging.ml", line 66, characters 2-25:
Warning 3: deprecated: Stdext.String.set
Use Bytes.set instead.
File "logging.ml", line 68, characters 6-10:
Error: This expression has type string but an expression was expected of type
         bytes
from xen-4.10.0/tools/ocaml/xenstored/logging.ml

Comment 5 Richard W.M. Jones 2017-12-16 23:29:55 UTC
Created attachment 1368874 [details]
xen-safe-strings.patch

The attached patch allows me to build Xen 4.10.

Comment 6 Michael Young 2017-12-18 22:18:31 UTC
(In reply to Richard W.M. Jones from comment #5)
> Created attachment 1368874 [details]
> xen-safe-strings.patch
> 
> The attached patch allows me to build Xen 4.10.

Thanks for that. It is building again thanks to your patch combined with a few lines I fixed and another unrelated fix.

Is it okay if I submit these fixes to upstream xen?

Comment 7 Richard W.M. Jones 2017-12-19 08:49:55 UTC
Sure, just go ahead, it's all open source.


Note You need to log in before you can comment on or make changes to this bug.