all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Ricardo Wurmus <rekado@elephly.net>
Cc: guix-devel@gnu.org
Subject: Re: 01/01: gnu: glibc/linux: Fix runtime crashes on i686 systems.
Date: Sun, 30 Apr 2017 04:16:42 -0400	[thread overview]
Message-ID: <87bmrewbrp.fsf@netris.org> (raw)
In-Reply-To: <20170429213255.095472109D@vcs0.savannah.gnu.org> (Ricardo Wurmus's message of "Sat, 29 Apr 2017 17:32:54 -0400 (EDT)")

Hi Ricardo,

rekado@elephly.net (Ricardo Wurmus) writes:

> rekado pushed a commit to branch master
> in repository guix.
>
> commit b2fd8f63679aa4f244c36fdca62f23c00b8eded9
> Author: Ricardo Wurmus <rekado@elephly.net>
> Date:   Wed Apr 26 13:03:48 2017 +0200
>
>     gnu: glibc/linux: Fix runtime crashes on i686 systems.
>     
>     * gnu/packages/patches/glibc-memchr-overflow-i686.patch: New file.
>     * gnu/local.mk (dist_patch_DATA): Add it.
>     * gnu/packages/commencement.scm (glibc-final-with-bootstrap-bash)[native-inputs]:
>     Add the patch conditionally for i686 systems.
>     * gnu/packages/base.scm (glibc/linux)[native-inputs]: Add the patch
>     conditionally for i686 systems.
>     [arguments]: Apply the patch conditionally on i686 systems.

Thanks very much for this.  I noticed a minor issue with this patch:

> diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
> index 9fcca45..6dc9e97 100644
> --- a/gnu/packages/base.scm
> +++ b/gnu/packages/base.scm
> @@ -666,6 +666,16 @@ store.")
>                          ;; 4.7.1.
>                          ((" -lgcc_s") ""))
>  
> +                      ;; Apply patch only on i686.
> +                      ;; TODO: Move the patch to 'patches' in the next update cycle.
> +                      ,@(if (string-prefix? "i686" (or (%current-target-system)
> +                                                       (%current-system)))
> +                            `(zero? (system* "patch" "-p1" "--force"
> +                                             "--input"
> +                                             (assoc-ref native-inputs
> +                                                        "glibc-memchr-overflow-i686.patch")))

The `(zero? ...) subexpression is incorrect for two reasons:

The first issue is that you need another layer of parentheses,
i.e. `((zero? ...)), to generate the code as you presumably intended.
As it is, the generated code looks like this:

--8<---------------cut here---------------start------------->8---
  (substitute* "Makeconfig"
    ;; According to
    ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
    ;; linking against libgcc_s is not needed with GCC
    ;; 4.7.1.
    ((" -lgcc_s") ""))

  zero?
  (system* "patch" "-p1" "--force"
           "--input"
           (assoc-ref native-inputs
                      "glibc-memchr-overflow-i686.patch"))
--8<---------------cut here---------------end--------------->8---

Since the isolated variable reference 'zero?' has no side effects and
the result is discarded, it has no effect and is presumably optimized
out.  'system*' returns an integer.  All integers are interpreted as
"true" in Scheme, including zero.

The other problem is that (zero? (system* ...)) does not have the
desired effect, because it is not the final expression in the outer
body, and therefore its result is discarded and errors are not flagged.

What's needed here is to explicitly raise an exception if 'system*'
returns a non-zero result, e.g. something like this (untested):

> +                      ;; Apply patch only on i686.
> +                      ;; TODO: Move the patch to 'patches' in the next update cycle.
> +                      ,@(if (string-prefix? "i686" (or (%current-target-system)
> +                                                       (%current-system)))
> +                            `((unless (zero? (system* "patch" "-p1" "--force"
> +                                                      "--input"
> +                                                      (assoc-ref native-inputs
> +                                                                 "glibc-memchr-overflow-i686.patch")))
> +                                (error "patch failed for glibc-memchr-overflow-i686.patch")))

This reminds me of something I've felt for a while: that we should stop
using 'system*' in most places, and instead use a variant of 'system*'
that automatically raises an exception in case of a non-zero result
code, but that's a subject for another thread.

Thoughts?

     Mark

       reply	other threads:[~2017-04-30  8:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170429213253.6080.61219@vcs0.savannah.gnu.org>
     [not found] ` <20170429213255.095472109D@vcs0.savannah.gnu.org>
2017-04-30  8:16   ` Mark H Weaver [this message]
2017-04-30  9:00     ` 01/01: gnu: glibc/linux: Fix runtime crashes on i686 systems Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bmrewbrp.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=guix-devel@gnu.org \
    --cc=rekado@elephly.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.