[rubygem-hpricot/f13/master] - Fix segfault on GC (bug 672169, patch suggested by TAGOH Akira)

Mamoru Tasaka mtasaka at fedoraproject.org
Tue Feb 1 16:59:15 UTC 2011


commit b424b543e9b5d9eb598d5dc1aad012234ed328ff
Author: Mamoru Tasaka <tasaka1 at localhost.localdomain>
Date:   Wed Feb 2 01:59:09 2011 +0900

    - Fix segfault on GC (bug 672169, patch suggested by TAGOH Akira)

 rubygem-hpricot-0.8.3-segv-on-GC.patch |   19 +++++++++++++++++++
 rubygem-hpricot.spec                   |   30 ++++++++++++++++++++++++------
 2 files changed, 43 insertions(+), 6 deletions(-)
---
diff --git a/rubygem-hpricot-0.8.3-segv-on-GC.patch b/rubygem-hpricot-0.8.3-segv-on-GC.patch
new file mode 100644
index 0000000..238abe8
--- /dev/null
+++ b/rubygem-hpricot-0.8.3-segv-on-GC.patch
@@ -0,0 +1,19 @@
+--- rubygem-hpricot-0.8.3.orig/usr/lib/ruby/gems/1.8/gems/hpricot-0.8.3/ext/hpricot_scan/hpricot_scan.rl	2011-01-24 18:20:45.703034829 +0900
++++ rubygem-hpricot-0.8.3.orig/usr/lib/ruby/gems/1.8/gems/hpricot-0.8.3/ext/hpricot_scan/hpricot_scan.rl	2011-01-24 18:36:49.159525528 +0900
+@@ -668,8 +668,14 @@ void hstruct_mark(void* ptr) {
+   struct hpricot_struct* st = (struct hpricot_struct*)ptr;
+   int i;
+ 
+-  for(i = 0; i < st->len; i++) {
+-    rb_gc_mark(st->ptr[i]);
++  /* it's likely to hit GC when allocating st->ptr.
++   * that should be checked to avoid segfault.
++   * and simply ignore it.
++   */
++  if (st->ptr) {
++    for(i = 0; i < st->len; i++) {
++      rb_gc_mark(st->ptr[i]);
++    }
+   }
+ }
+ 
diff --git a/rubygem-hpricot.spec b/rubygem-hpricot.spec
index d3d6c44..389d52c 100644
--- a/rubygem-hpricot.spec
+++ b/rubygem-hpricot.spec
@@ -10,7 +10,7 @@
 Summary:	A Fast, Enjoyable HTML Parser for Ruby
 Name:		rubygem-%{gemname}
 Version:	0.8.3
-Release:	1%{?dist}
+Release:	2%{?dist}
 Group:		Development/Languages
 # ext/fast_xs/FastXsService.java is licensed under ASL 2.0
 License:	MIT and ASL 2.0
@@ -19,10 +19,16 @@ URL:		http://github.com/hpricot/hpricot
 # Source0:	http://gems.rubyforge.org/gems/%{gemname}-%{version}.gem
 Source0:	%{gemname}-%{version}-modified.gem
 Source10:	rubygem-hpricot-create-free-gem.sh
+# hpricot 0.8.3 segfaults on GC
+# RH: bug 672169
+# Upstream: https://github.com/hpricot/hpricot/issues/#issue/32
+Patch0:		rubygem-hpricot-0.8.3-segv-on-GC.patch
 
-BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires:	ruby(abi) = %{rubyabi}
 BuildRequires:	ruby(rubygems)
+# Recompile
+BuildRequires:	rubygem(rake)
+# Others
 BuildRequires:	rubygem(rake-compiler)
 BuildRequires:	ruby-devel
 BuildRequires:	ragel
@@ -70,13 +76,22 @@ grep -rl BOING . | \
 	xargs sed -i '/BOING/s|^\([ \t][ \t]*\)\(.*\)$|\1# This test is intentionally killed\n\1return true\n\1\2|'
 popd
 
+# Patch
+pushd .%{geminstdir}
+%patch0 -p8
+popd
+
 # ??
 find . -type f | xargs chmod ugo+r
 
 %build
+# Recompile
+pushd .%{geminstdir}
+rake clean
+rake
+popd
 
 %install
-rm -rf %{buildroot}
 mkdir -p %{buildroot}%{gemdir}
 cp -a ./%{gemdir}/* %{buildroot}%{gemdir}
 
@@ -90,6 +105,9 @@ do
 	chmod 0644 $f
 done
 
+# clean
+rm -rf %{buildroot}%{geminstdir}/tmp/
+
 # Kill unneeded files
 find %{buildroot}%{geminstdir}/ext \
 	-type f \
@@ -174,9 +192,6 @@ pushd .%{geminstdir}
 rake test
 popd
 
-%clean
-rm -rf %{buildroot}
-
 %files
 %defattr(-,root, root,-)
 %{ruby_sitearch}/*.so
@@ -200,6 +215,9 @@ rm -rf %{buildroot}
 %{ruby_sitelib}/%{gemname}/
 
 %changelog
+* Wed Feb  2 2011 Mamoru Tasaka <mtasaka at ioa.s.u-tokyo.ac.jp> - 0.8.3-2
+- Fix segfault on GC (bug 672169, patch suggested by TAGOH Akira)
+
 * Sat Nov  6 2010 Mamoru Tasaka <mtasaka at ioa.s.u-tokyo.ac.jp> - 0.8.3-1
 - 0.8.3
 


More information about the scm-commits mailing list