Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@stusta.de>
To: mingli.yu@windriver.com
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH v4 1/2] nettle: fix the Segmentation fault
Date: Wed, 24 Apr 2019 12:21:35 +0300	[thread overview]
Message-ID: <20190424092135.GA19130@localhost> (raw)
In-Reply-To: <1556095261-171895-1-git-send-email-mingli.yu@windriver.com>

On Wed, Apr 24, 2019 at 04:41:00PM +0800, mingli.yu@windriver.com wrote:
> From: Mingli Yu <Mingli.Yu@windriver.com>
> 
> The commit[8ac8fa8ee1 nettle: update to 3.4.1]
> add CFLAGS_append = " -std=c99" to silence the
> below error for native build:
> | ../nettle-3.4.1/rsa-sign-tr.c: In function 'sec_equal':
> | ../nettle-3.4.1/rsa-sign-tr.c:243:3: error: 'for' loop initial declarations are only allowed in C99 mode
>    for (size_t i = 0; i < limbs; i++)
>    ^
> | ../nettle-3.4.1/rsa-sign-tr.c:243:3: note: use option -std=c99 or -std=gnu99 to compile your code
> | Makefile:263: recipe for target 'rsa-sign-tr.o' failed
> 
> But the above change will trigger below Segmentation
> fault:
>  # echo -n passwd| nettle-pbkdf2 -i 1 -l 16 salt
>  [65534.886509] nettle-pbkdf2[708]: segfault at 1f594260 ip 00007f3332256998 sp 00007fff60d44410 error 4 in libnettle.so.6.5[7f3332244000+1d00]
>  [65534.887525] Code: e8 6d db fe ff 44 01 6d 68 48 83 c4 08 5b 5d 41 5c 41 5d 41 5e 41 5f c3 66 2e 0f 1f 84 00 00 00 00 00 49 89 dc e9 68 ff f
>  Segmentation fault
> 
> So update the logic to CFLAGS_append = " -std=gnu99"
> to fix the issue.
> 
> Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
> ---
>  meta/recipes-support/nettle/nettle_3.4.1.bb | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/recipes-support/nettle/nettle_3.4.1.bb b/meta/recipes-support/nettle/nettle_3.4.1.bb
> index dd49c30..8375fcf 100644
> --- a/meta/recipes-support/nettle/nettle_3.4.1.bb
> +++ b/meta/recipes-support/nettle/nettle_3.4.1.bb
> @@ -30,7 +30,7 @@ inherit autotools ptest multilib_header
>  EXTRA_AUTORECONF += "--exclude=aclocal"
>  
>  EXTRA_OECONF = "--disable-openssl"
> -CFLAGS_append = " -std=c99"
> +CFLAGS_append = " -std=gnu99"
>...

Nice catch.

Looking at the build log, setting a C mode without GNU extensions 
resulted in

../../nettle-3.4.1/tools/nettle-pbkdf2.c: In function 'main':
../../nettle-3.4.1/tools/nettle-pbkdf2.c:144:10: warning: implicit declaration of function 'strdup'; did you mean 'strcmp'? [-Wimplicit-function-declaration]
   salt = strdup (argv[0]);
          ^~~~~~
          strcmp
../../nettle-3.4.1/tools/nettle-pbkdf2.c:144:10: warning: nested extern declaration of 'strdup' [-Wnested-externs]
../../nettle-3.4.1/tools/nettle-pbkdf2.c:144:8: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   salt = strdup (argv[0]);
        ^

It is obvious why the resulting code crashed.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed



  parent reply	other threads:[~2019-04-24  9:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-12  3:27 [PATCH] nettle: fix ptest failure mingli.yu
2019-04-12 21:57 ` Richard Purdie
2019-04-15  2:10   ` Yu, Mingli
2019-04-15  7:40   ` [PATCH v2] " mingli.yu
2019-04-15  7:59     ` richard.purdie
2019-04-15  8:09       ` Yu, Mingli
2019-04-15  8:06         ` richard.purdie
2019-04-15  8:39           ` Adrian Bunk
2019-04-15  8:43           ` Yu, Mingli
2019-04-15  9:05           ` [PATCH v3] " mingli.yu
2019-04-15 11:08             ` richard.purdie
2019-04-16  3:14               ` Yu, Mingli
2019-04-18  5:30                 ` Yu, Mingli
2019-04-24  8:41                   ` [PATCH v4 1/2] nettle: fix the Segmentation fault mingli.yu
2019-04-24  8:41                     ` [PATCH v4 2/2] nettle: fix ptest failure mingli.yu
2019-04-24  9:21                     ` Adrian Bunk [this message]
2019-04-29  6:48                     ` [PATCH v4 1/2] nettle: fix the Segmentation fault Yu, Mingli
2019-05-11  1:27                     ` Khem Raj

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=20190424092135.GA19130@localhost \
    --to=bunk@stusta.de \
    --cc=mingli.yu@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox