Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Mark Hatle <mark.hatle@windriver.com>
To: Kai Kang <kai.kang@windriver.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH 1/1] rpm: fix rpm2cpio segmentation fault
Date: Mon, 30 Sep 2013 09:02:26 -0500	[thread overview]
Message-ID: <52498472.8080204@windriver.com> (raw)
In-Reply-To: <4092f836c8e0d512fa2f0b4378766820a16e4957.1380534395.git.kai.kang@windriver.com>

On 9/30/13 4:48 AM, Kai Kang wrote:
> From: Kang Kai <kai.kang@windriver.com>
>
> When run rpm2cpio, it fails with segmentation fault. The root cause is
> no macros "_db_path" and "_dbi_config*" defined, when query these macros
> get nothing then cause segment fault.
>
> Add patch to parse macro files first to fix this problem.

I talked briefly with the RPM maintainer about this a while back.

I don't think this is the right patch.  Not because what it does is wrong.  (The 
patch itself is actually likely correct in the general case.)  However, the 
proper fix is to simply use the rpm2cpio shell script, and never install the 
binary.  (This does introduce a dependency on 'file', but I don't believe that 
should be a major concern.)

So my suggestion is to rework this fix by:

1) Keep what you have below (why?  because if someone really wants the binary 
it'll prevent the segfault.)

2) Change the recipe's do_install to copy in the rpm2cpio.sh and replace the 
binary version.

3) Ensure that the package that rpm2cpio is in gets a dependency on 'file'.

--Mark

> [YOCTO #3656]
>
> Signed-off-by: Kang Kai <kai.kang@windriver.com>
> ---
>   .../rpm/rpm/rpm2cpio-fix-segmentation-fault.patch  | 28 ++++++++++++++++++++++
>   meta/recipes-devtools/rpm/rpm_5.4.9.bb             |  1 +
>   2 files changed, 29 insertions(+)
>   create mode 100644 meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch
>
> diff --git a/meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch b/meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch
> new file mode 100644
> index 0000000..cdf8fb1
> --- /dev/null
> +++ b/meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch
> @@ -0,0 +1,28 @@
> +Upstream-Status: Pending
> +
> +rpm2cpio fails on target with "Segmentation fault". Because macros
> +"_dbpath" and "_dbi_config*" need to be defined, otherwise query these
> +macros will cause segment fault.
> +
> +Parse config files first to fix this bug. If parse fails, give a warning.
> +
> +[YOCTO #3656]
> +
> +Signed-off-by: Kang Kai <kai.kang@windriver.com>
> +
> +--- rpm-5.4.9/tools/rpm2cpio.c.orig	2013-04-15 10:35:14.269398890 +0800
> ++++ rpm-5.4.9/tools/rpm2cpio.c	2013-04-15 10:44:12.777417885 +0800
> +@@ -87,6 +87,13 @@
> + #endif
> + 	(void) rpmtsSetVSFlags(ts, vsflags);
> +
> ++	/* If macros "_dbpath" and "_dbi_config*" are not defined,
> ++	 * sigment fault occurs */
> ++	rc = rpmReadConfigFiles(NULL, NULL);
> ++	if (rc) {
> ++		fprintf(stderr, _("Read RPM config files failed that may cause sigment fault.\n"));
> ++	}
> ++
> + 	/*@-mustmod@*/      /* LCL: segfault */
> + 	rc = rpmReadPackageFile(ts, fdi, "rpm2cpio", &h);
> + 	/*@=mustmod@*/
> diff --git a/meta/recipes-devtools/rpm/rpm_5.4.9.bb b/meta/recipes-devtools/rpm/rpm_5.4.9.bb
> index 3c7e03b..492393e 100644
> --- a/meta/recipes-devtools/rpm/rpm_5.4.9.bb
> +++ b/meta/recipes-devtools/rpm/rpm_5.4.9.bb
> @@ -88,6 +88,7 @@ SRC_URI = "http://www.rpm5.org/files/rpm/rpm-5.4/rpm-5.4.9-0.20120508.src.rpm;ex
>   	   file://debugedit-segv.patch \
>   	   file://rpm-platform-file-fix.patch \
>   	   file://rpm-lsb-compatibility.patch \
> +	   file://rpm2cpio-fix-segmentation-fault.patch \
>   	  "
>
>   # Uncomment the following line to enable platform score debugging
>



  reply	other threads:[~2013-09-30 14:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-30  9:48 [PATCH 0/1] Fix YOCTO #3656 Kai Kang
2013-09-30  9:48 ` [PATCH 1/1] rpm: fix rpm2cpio segmentation fault Kai Kang
2013-09-30 14:02   ` Mark Hatle [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-04-15  3:17 [PATCH 0/1] V2: Fix rpm2cpio segment fault Kang Kai
2013-04-15  3:17 ` [PATCH 1/1] rpm: fix rpm2cpio segmentation fault Kang Kai
2013-02-28  7:34 [PATCH 0/1] Fix rpm2cpio segment fault Kang Kai
2013-02-28  7:34 ` [PATCH 1/1] rpm: fix rpm2cpio segmentation fault Kang Kai
2013-02-28 14:34   ` Mark Hatle
2013-03-12  5:57     ` Kang Kai
2013-03-12 15:30       ` Mark Hatle
2013-04-12  9:18         ` Kang Kai

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=52498472.8080204@windriver.com \
    --to=mark.hatle@windriver.com \
    --cc=kai.kang@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