Bug 189710 - lang/ocaml: ocamlbuild doesn't handle SIGPIPE
Summary: lang/ocaml: ocamlbuild doesn't handle SIGPIPE
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: John Marino
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-12 14:50 UTC by Török Edwin
Modified: 2014-08-19 14:09 UTC (History)
2 users (show)

See Also:


Attachments
Patch for lang/ocaml (1.67 KB, patch)
2014-08-19 12:52 UTC, Michael Grünewald
michipili: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Török Edwin 2014-05-12 14:50:01 UTC
        If ocamlfind prints a warning during build then ocamlbuild fails like this:
        /usr/local/bin/ocamlfind ocamlc -where > /usr/ports/devel/ocaml-pcre/work/pcre-ocaml-7.0.4/_build/ocamlc.where
        Command got signal -8.

        If I run the ocamlfind command manually it works, but it prints a warning too:
        ocamlfind: [WARNING] Cannot read directory /usr/ports/devel/ocaml-pcre/work/stage/usr/local/lib/ocaml/site-lib/pcre which is mentioned in ld.conf

        That warnings causes a SIGPIPE in ocamlbuild or somewhere, which causes the signal -8 message to be printed:
        You can use 'truss -f make' to confirm:
        75895: write(2,"ocamlfind: [WARNING] Cannot read"...,146) ERR#32 'Broken pipe'
        75895: SIGNAL 13 (SIGPIPE)
        75895: process exit, rval = 0
        75889: wait4(75895,{ SIGNALED,sig=SIGPIPE },0x0,0x0) = 75895 (0x12877)
        75889: write(1,"\r\^[[K",4)                      = 4 (0x4)
        + ocamlfind ocamlc -where > /usr/ports/textproc/ocaml-text/work/ocaml-text-0.6/_build/ocamlc.where
        75889: write(1,"+ ocamlfind ocamlc -where > /usr"...,103) = 103 (0x67)
        75889: close(4)                                  = 0 (0x0)
        75889: write(3,"+ ocamlfind ocamlc -where > /usr"...,150) = 150 (0x96)
        75889: close(3)                                  = 0 (0x0)
        75889: gettimeofday({1399897227.200087 },0x0)    = 0 (0x0)
        Command got signal -8.

        This is not related to a particular OCaml package, I got this on ocaml-pcre or ocaml-text, but others have encountered this issue elsewhere:
        https://bugzilla.skylable.com/show_bug.cgi?id=470#c3
        https://github.com/the-lambda-church/merlin/issues/193
        https://github.com/the-lambda-church/merlin/issues/183

        I don't know if this is related to GCC or Clang (my system seems to use Clang), but this appears to be a
        FreeBSD-specific problem with ocamlbuild (on Linux I've never seen this error).

Fix: 

Run 'ocamlfind ocamlc -where' manually
        Edit /usr/local/lib/ocaml/ld.conf and remove the lines it complained about
How-To-Repeat:         Install the ocaml compiler (from source, see other PR as binary package seems to be missing):
        # cd /usr/ports/lang/ocaml
        # make install
        # cd /usr/ports/textproc/ocaml-text
        # make install
        [...]

        Oh this wants to build PCRE, but there's a binary package, ... interrupt the build!
        [..]
        ^C

        Install pcre binary package
        # pkg install pcre

        OK lets resume
        # make install
        [....]
        + /usr/local/bin/ocamlfind ocamlc -where > /usr/ports/devel/ocaml-pcre/work/pcre-ocaml-7.0.4/_build/ocamlc.where
        Command got signal -8.

        Expected behaviour:
        ocamlbuild should print the error message from ocamlfind's stderr, instead of dieing on SIGPIPE!
Comment 1 Török Edwin 2014-05-12 15:17:30 UTC
Note: ocamlbuild is part of lang/ocaml in ports.
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2014-05-13 05:49:50 UTC
Maintainer of lang/ocaml,

Please note that PR ports/189710 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/189710

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 3 Edwin Groothuis freebsd_committer freebsd_triage 2014-05-13 05:49:51 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 4 John Marino freebsd_committer freebsd_triage 2014-07-13 08:09:10 UTC
Reassigning to maintainer.  This got lost in the transition to bugzilla.
Comment 5 John Marino freebsd_committer freebsd_triage 2014-08-11 10:30:33 UTC
Michael, any idea?
Comment 6 Michael Grünewald 2014-08-11 11:01:12 UTC
There is a seemingly-related bug-report[1] upstream.  It seems that there is a
patch for this.  I will investigate the issue to reproduce it and see if the patch helps.

http://caml.inria.fr/mantis/view.php?id=5371
Comment 7 John Marino freebsd_committer freebsd_triage 2014-08-12 12:27:48 UTC
unrelated, but in 2 weeks the following ports are going to be removed:


devel/ocaml-camomile
devel/ocaml-equeue
devel/ocaml-event
devel/ocaml-sdl
devel/ocamlweb
databases/ocaml-pgocaml
lang/metaocaml
lang/ocaml-camlidl
lang/ocaml-mode

You may want to stage and adopt some?  I don't know.  Just letting you know.
Comment 8 Michael Grünewald 2014-08-12 12:36:12 UTC
John, thank you for pointing this out, I will take a look at this as well!
Comment 9 Michael Grünewald 2014-08-19 12:52:54 UTC
Created attachment 146031 [details]
Patch for lang/ocaml

I applied upstream patch for the issue number 0005371 (upstream issue) and
could build and reinstall and OCaml, and was able to build and install
textproc/ocaml-text with the corrected ocamlbuild.

The patch has git a/b headers, so it might require stripping before applying it in /usr/ports.

Suggested commit message:

    lang/ocaml: Improve jobcontrol in ocamlbuild
    
    Apply patch for upstream issue 0005371. It improves jobcontrol in
    ocamlbuild and fixes some faulty sigpipe affecting ports built
    with ocamlbuild.
    
    PR:         189710
    Submitted by:       maintainer (Michael Gruenewald)
    Patch by:   glondu
Comment 10 John Marino freebsd_committer freebsd_triage 2014-08-19 12:55:37 UTC
the a/ b/ thing is unfortunate.  I have to manually remove those for it to work with svn patch. For regular patch it's no problem, -p 1 fixes it.
Comment 11 commit-hook freebsd_committer freebsd_triage 2014-08-19 13:55:33 UTC
A commit references this bug:

Author: marino
Date: Tue Aug 19 13:55:12 UTC 2014
New revision: 365380
URL: http://svnweb.freebsd.org/changeset/ports/365380

Log:
  lang/ocaml: Improve jobcontrol in ocamlbuild

  Apply patch for upstream issue 0005371.  It improves job control in
  ocamlbuild and fixes some faulty sigpipe affecting ports build with
  ocamlbuild.

  PR:		189710
  Submitted by:	edwin (skylable.com)
  patch by:	glondu
  Approved by:	maintainer (Michael Gruenewald)

Changes:
  head/lang/ocaml/Makefile
  head/lang/ocaml/files/patch-ocamlbuild
Comment 12 John Marino freebsd_committer freebsd_triage 2014-08-19 13:56:22 UTC
Thanks, Michael.
Comment 13 Michael Grünewald 2014-08-19 14:06:39 UTC
Great!

For the a/ b/ thing I am currently using git for my work on ports because
I know it quite well and gave up subversion for about 4 or 5 years. So, I am
asking, if you would recommend to use subversion for working on ports?  Would
it be kind of easier to generate patches and stay up-to-date?
Comment 14 John Marino freebsd_committer freebsd_triage 2014-08-19 14:09:23 UTC
(In reply to Michael Grünewald from comment #13)
> Great!
> 
> For the a/ b/ thing I am currently using git for my work on ports because
> I know it quite well and gave up subversion for about 4 or 5 years. So, I am
> asking, if you would recommend to use subversion for working on ports?  Would
> it be kind of easier to generate patches and stay up-to-date?

I think it would be a little easier but not mandatory.  Obviously I was able to cope.  If you submit diffs without that a/ b/ diff Index stuff (and there must be an option for that) then it wouldn't make a difference at all.