1 |
commit: 66c99889dcca8a6aa17749062568a78a6319be45 |
2 |
Author: Hans de Graaff <hans <AT> degraaff <DOT> org> |
3 |
AuthorDate: Fri Apr 20 10:43:58 2012 +0000 |
4 |
Commit: Hans de Graaff <graaff <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Apr 20 10:43:58 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ruby-scripts.git;a=commit;h=66c99889 |
7 |
|
8 |
New patchset for ruby 1.8.7 p358. |
9 |
|
10 |
Note that patch 014 is actually upstream p359, but that version is not yet |
11 |
released as a tarball. |
12 |
|
13 |
--- |
14 |
patchsets/patches-1.8.7_p358/001_memory_leak.patch | 59 +++ |
15 |
.../003_mkmf-parallel-install.patch | 16 + |
16 |
patchsets/patches-1.8.7_p358/004_berkdb-5.0.patch | 13 + |
17 |
.../patches-1.8.7_p358/007_no-undefined-ext.patch | 13 + |
18 |
patchsets/patches-1.8.7_p358/008_ppc64.patch | 42 +++ |
19 |
.../patches-1.8.7_p358/013_CVE-2011-0188.patch | 14 + |
20 |
.../patches-1.8.7_p358/014_marshall-bug.patch | 369 ++++++++++++++++++++ |
21 |
patchsets/patches-1.8.7_p358/series | 7 + |
22 |
8 files changed, 533 insertions(+), 0 deletions(-) |
23 |
|
24 |
diff --git a/patchsets/patches-1.8.7_p358/001_memory_leak.patch b/patchsets/patches-1.8.7_p358/001_memory_leak.patch |
25 |
new file mode 100644 |
26 |
index 0000000..98edae0 |
27 |
--- /dev/null |
28 |
+++ b/patchsets/patches-1.8.7_p358/001_memory_leak.patch |
29 |
@@ -0,0 +1,59 @@ |
30 |
+Index: ruby-1.8.7-p299/ext/dl/handle.c |
31 |
+=================================================================== |
32 |
+--- ruby-1.8.7-p299.orig/ext/dl/handle.c |
33 |
++++ ruby-1.8.7-p299/ext/dl/handle.c |
34 |
+@@ -10,9 +10,12 @@ VALUE rb_cDLHandle; |
35 |
+ void |
36 |
+ dlhandle_free(struct dl_handle *dlhandle) |
37 |
+ { |
38 |
++ if (!dlhandle) |
39 |
++ return; |
40 |
+ if (dlhandle->ptr && dlhandle->open && dlhandle->enable_close) { |
41 |
+ dlclose(dlhandle->ptr); |
42 |
+ } |
43 |
++ dlfree(dlhandle); |
44 |
+ } |
45 |
+ |
46 |
+ VALUE |
47 |
+Index: ruby-1.8.7-p299/ext/dl/ptr.c |
48 |
+=================================================================== |
49 |
+--- ruby-1.8.7-p299.orig/ext/dl/ptr.c |
50 |
++++ ruby-1.8.7-p299/ext/dl/ptr.c |
51 |
+@@ -45,6 +45,8 @@ rb_dlmem_aref(void *ptr) |
52 |
+ void |
53 |
+ dlptr_free(struct ptr_data *data) |
54 |
+ { |
55 |
++ if (!data) |
56 |
++ return; |
57 |
+ if (data->ptr) { |
58 |
+ DEBUG_CODE({ |
59 |
+ printf("dlptr_free(): removing the pointer `0x%x' from the MemorySpace\n", |
60 |
+@@ -61,6 +63,7 @@ dlptr_free(struct ptr_data *data) |
61 |
+ if (data->stype) dlfree(data->stype); |
62 |
+ if (data->ssize) dlfree(data->ssize); |
63 |
+ if (data->ids) dlfree(data->ids); |
64 |
++ dlfree(data); |
65 |
+ } |
66 |
+ |
67 |
+ void |
68 |
+Index: ruby-1.8.7-p299/ext/dl/sym.c |
69 |
+=================================================================== |
70 |
+--- ruby-1.8.7-p299.orig/ext/dl/sym.c |
71 |
++++ ruby-1.8.7-p299/ext/dl/sym.c |
72 |
+@@ -57,6 +57,8 @@ char2type(int ch) |
73 |
+ void |
74 |
+ dlsym_free(struct sym_data *data) |
75 |
+ { |
76 |
++ if(!data) |
77 |
++ return; |
78 |
+ if( data->name ){ |
79 |
+ DEBUG_CODE({ |
80 |
+ printf("dlsym_free(): free(data->name:%s)\n",data->name); |
81 |
+@@ -69,6 +71,7 @@ dlsym_free(struct sym_data *data) |
82 |
+ }); |
83 |
+ free(data->type); |
84 |
+ } |
85 |
++ dlfree(data); |
86 |
+ } |
87 |
+ |
88 |
+ VALUE |
89 |
|
90 |
diff --git a/patchsets/patches-1.8.7_p358/003_mkmf-parallel-install.patch b/patchsets/patches-1.8.7_p358/003_mkmf-parallel-install.patch |
91 |
new file mode 100644 |
92 |
index 0000000..9ecdc9b |
93 |
--- /dev/null |
94 |
+++ b/patchsets/patches-1.8.7_p358/003_mkmf-parallel-install.patch |
95 |
@@ -0,0 +1,16 @@ |
96 |
+ Patch for bug 239101 by Matsuu Takuto, via Redmine issue 1337 (yes, really). |
97 |
+ Backported for 1.8.* by Alex Legler. |
98 |
+ |
99 |
+Index: ruby-1.8.7-p299/lib/mkmf.rb |
100 |
+=================================================================== |
101 |
+--- ruby-1.8.7-p299.orig/lib/mkmf.rb |
102 |
++++ ruby-1.8.7-p299/lib/mkmf.rb |
103 |
+@@ -1523,7 +1523,7 @@ static: $(STATIC_LIB)#{$extout ? " inst |
104 |
+ dest = "#{dir}/#{f}" |
105 |
+ mfile.puts dir, "install-so: #{dest}" |
106 |
+ unless $extout |
107 |
+- mfile.print "#{dest}: #{f}\n" |
108 |
++ mfile.print "#{dest}: #{dir} #{f}\n" |
109 |
+ if (sep = config_string('BUILD_FILE_SEPARATOR')) |
110 |
+ f.gsub!("/", sep) |
111 |
+ dir.gsub!("/", sep) |
112 |
|
113 |
diff --git a/patchsets/patches-1.8.7_p358/004_berkdb-5.0.patch b/patchsets/patches-1.8.7_p358/004_berkdb-5.0.patch |
114 |
new file mode 100644 |
115 |
index 0000000..2516cd3 |
116 |
--- /dev/null |
117 |
+++ b/patchsets/patches-1.8.7_p358/004_berkdb-5.0.patch |
118 |
@@ -0,0 +1,13 @@ |
119 |
+Index: ruby-1.8.7-p299/ext/dbm/extconf.rb |
120 |
+=================================================================== |
121 |
+--- ruby-1.8.7-p299.orig/ext/dbm/extconf.rb |
122 |
++++ ruby-1.8.7-p299/ext/dbm/extconf.rb |
123 |
+@@ -26,7 +26,7 @@ def headers.db_check(db) |
124 |
+ case db |
125 |
+ when /^db2?$/ |
126 |
+ db_prefix = "__db_n" |
127 |
+- hsearch = "-DDB_DBM_HSEARCH " |
128 |
++ hsearch = "-DDB_DBM_HSEARCH -DHAVE_DBM " |
129 |
+ when "gdbm" |
130 |
+ have_gdbm = true |
131 |
+ when "gdbm_compat" |
132 |
|
133 |
diff --git a/patchsets/patches-1.8.7_p358/007_no-undefined-ext.patch b/patchsets/patches-1.8.7_p358/007_no-undefined-ext.patch |
134 |
new file mode 100644 |
135 |
index 0000000..41a7ddb |
136 |
--- /dev/null |
137 |
+++ b/patchsets/patches-1.8.7_p358/007_no-undefined-ext.patch |
138 |
@@ -0,0 +1,13 @@ |
139 |
+Index: ruby-1.8.7-p299/configure.in |
140 |
+=================================================================== |
141 |
+--- ruby-1.8.7-p299.orig/configure.in |
142 |
++++ ruby-1.8.7-p299/configure.in |
143 |
+@@ -1223,7 +1223,7 @@ if test "$with_dln_a_out" != yes; then |
144 |
+ linux* | gnu* | k*bsd*-gnu | netbsd* | bsdi*) |
145 |
+ : ${LDSHARED='${CC} -shared'} |
146 |
+ if test "$rb_cv_binary_elf" = yes; then |
147 |
+- LDFLAGS="$LDFLAGS -Wl,-export-dynamic" |
148 |
++ LDFLAGS="$LDFLAGS -Wl,-export-dynamic -Wl,--no-undefined" |
149 |
+ fi |
150 |
+ rb_cv_dlopen=yes ;; |
151 |
+ interix*) : ${LDSHARED="$CC -shared"} |
152 |
|
153 |
diff --git a/patchsets/patches-1.8.7_p358/008_ppc64.patch b/patchsets/patches-1.8.7_p358/008_ppc64.patch |
154 |
new file mode 100644 |
155 |
index 0000000..9a52cd7 |
156 |
--- /dev/null |
157 |
+++ b/patchsets/patches-1.8.7_p358/008_ppc64.patch |
158 |
@@ -0,0 +1,42 @@ |
159 |
+ diff --git a/eval.c b/eval.c |
160 |
+ index a54fdce..e25ee24 100644 |
161 |
+ --- a/eval.c |
162 |
+ +++ b/eval.c |
163 |
+ @@ -188,6 +188,9 @@ int function_call_may_return_twice_false_2 = 0; |
164 |
+ (function_call_may_return_twice_false_2 ? \ |
165 |
+ setjmp(function_call_may_return_twice_jmp_buf) : \ |
166 |
+ 0) |
167 |
+ +# elif defined(__PPC64__) |
168 |
+ +# define JUST_BEFORE_SETJMP(extra_save, j) ((void)0) |
169 |
+ +# define JUST_AFTER_SETJMP(extra_save, j) ((j)->status ? (void)0 : (extra_save)) |
170 |
+ # elif defined(__FreeBSD__) && __FreeBSD__ < 7 |
171 |
+ /* |
172 |
+ * workaround for FreeBSD/i386 getcontext/setcontext bug. |
173 |
+ @@ -205,16 +208,23 @@ static int volatile freebsd_clear_carry_flag = 0; |
174 |
+ # ifndef POST_GETCONTEXT |
175 |
+ # define POST_GETCONTEXT 0 |
176 |
+ # endif |
177 |
+ +# ifndef JUST_BEFORE_SETJMP |
178 |
+ +# define JUST_BEFORE_SETJMP(extra_save, j) (extra_save) |
179 |
+ +# endif |
180 |
+ +# ifndef JUST_AFTER_SETJMP |
181 |
+ +# define JUST_AFTER_SETJMP(extra_save, j) ((void)0) |
182 |
+ +# endif |
183 |
+ # define ruby_longjmp(env, val) rb_jump_context(env, val) |
184 |
+ -# define ruby_setjmp(just_before_setjmp, j) ((j)->status = 0, \ |
185 |
+ - (just_before_setjmp), \ |
186 |
+ +# define ruby_setjmp(extra_save, j) ((j)->status = 0, \ |
187 |
+ + JUST_BEFORE_SETJMP(extra_save, j), \ |
188 |
+ PRE_GETCONTEXT, \ |
189 |
+ getcontext(&(j)->context), \ |
190 |
+ POST_GETCONTEXT, \ |
191 |
+ + JUST_AFTER_SETJMP(extra_save, j), \ |
192 |
+ (j)->status) |
193 |
+ #else |
194 |
+ -# define ruby_setjmp(just_before_setjmp, env) \ |
195 |
+ - ((just_before_setjmp), RUBY_SETJMP(env)) |
196 |
+ +# define ruby_setjmp(extra_save, env) \ |
197 |
+ + ((extra_save), RUBY_SETJMP(env)) |
198 |
+ # define ruby_longjmp(env,val) RUBY_LONGJMP(env,val) |
199 |
+ # ifdef __CYGWIN__ |
200 |
+ # ifndef _setjmp |
201 |
|
202 |
diff --git a/patchsets/patches-1.8.7_p358/013_CVE-2011-0188.patch b/patchsets/patches-1.8.7_p358/013_CVE-2011-0188.patch |
203 |
new file mode 100644 |
204 |
index 0000000..9e29917 |
205 |
--- /dev/null |
206 |
+++ b/patchsets/patches-1.8.7_p358/013_CVE-2011-0188.patch |
207 |
@@ -0,0 +1,14 @@ |
208 |
+Patch backported from upstream revision 30993 by a3li@g.o. |
209 |
+ |
210 |
+diff -Naur ruby-1.8.7-p334.orig/ext/bigdecimal/bigdecimal.c ruby-1.8.7-p334/ext/bigdecimal/bigdecimal.c |
211 |
+--- ruby-1.8.7-p334.orig/ext/bigdecimal/bigdecimal.c 2010-06-08 09:49:18.000000000 +0200 |
212 |
++++ ruby-1.8.7-p334/ext/bigdecimal/bigdecimal.c 2011-05-31 20:53:23.268999218 +0200 |
213 |
+@@ -2032,7 +2032,7 @@ |
214 |
+ VP_EXPORT void * |
215 |
+ VpMemAlloc(U_LONG mb) |
216 |
+ { |
217 |
+- void *p = xmalloc((unsigned int)mb); |
218 |
++ void *p = xmalloc(mb); |
219 |
+ if(!p) { |
220 |
+ VpException(VP_EXCEPTION_MEMORY,"failed to allocate memory",1); |
221 |
+ } |
222 |
|
223 |
diff --git a/patchsets/patches-1.8.7_p358/014_marshall-bug.patch b/patchsets/patches-1.8.7_p358/014_marshall-bug.patch |
224 |
new file mode 100644 |
225 |
index 0000000..5c541f0 |
226 |
--- /dev/null |
227 |
+++ b/patchsets/patches-1.8.7_p358/014_marshall-bug.patch |
228 |
@@ -0,0 +1,369 @@ |
229 |
+Index: ChangeLog |
230 |
+=================================================================== |
231 |
+--- ChangeLog (revision 34866) |
232 |
++++ ChangeLog (revision 34867) |
233 |
+@@ -1,3 +1,17 @@ |
234 |
++Fri Mar 2 11:44:33 2012 Nobuyoshi Nakada <nobu@×××××××××.org> |
235 |
++ |
236 |
++ * marshal.c (mark_dump_arg): mark destination string. patch by |
237 |
++ Vit Ondruch. [Bug #4339] |
238 |
++ |
239 |
++ * marshal.c (clear_dump_arg, clear_load_arg): clean up also data |
240 |
++ tables as same as symbols tables. |
241 |
++ |
242 |
++Fri Mar 2 11:44:33 2012 Nobuyoshi Nakada <nobu@×××××××××.org> |
243 |
++ |
244 |
++ * marshal.c (struct {dump,load}_arg): manage with dfree, instead |
245 |
++ of using local variable which may be moved by context switch. |
246 |
++ [ruby-dev:39425] |
247 |
++ |
248 |
+ Wed Feb 8 14:06:59 2012 Hiroshi Nakamura <nahi@×××××××××.org> |
249 |
+ |
250 |
+ * ext/openssl/ossl_ssl.c: Add SSL constants and allow to unset SSL |
251 |
+Index: version.h |
252 |
+=================================================================== |
253 |
+--- version.h (revision 34866) |
254 |
++++ version.h (revision 34867) |
255 |
+@@ -1,15 +1,15 @@ |
256 |
+ #define RUBY_VERSION "1.8.7" |
257 |
+-#define RUBY_RELEASE_DATE "2012-02-08" |
258 |
++#define RUBY_RELEASE_DATE "2012-03-02" |
259 |
+ #define RUBY_VERSION_CODE 187 |
260 |
+-#define RUBY_RELEASE_CODE 20120208 |
261 |
+-#define RUBY_PATCHLEVEL 358 |
262 |
++#define RUBY_RELEASE_CODE 20120302 |
263 |
++#define RUBY_PATCHLEVEL 359 |
264 |
+ |
265 |
+ #define RUBY_VERSION_MAJOR 1 |
266 |
+ #define RUBY_VERSION_MINOR 8 |
267 |
+ #define RUBY_VERSION_TEENY 7 |
268 |
+ #define RUBY_RELEASE_YEAR 2012 |
269 |
+-#define RUBY_RELEASE_MONTH 2 |
270 |
+-#define RUBY_RELEASE_DAY 8 |
271 |
++#define RUBY_RELEASE_MONTH 3 |
272 |
++#define RUBY_RELEASE_DAY 2 |
273 |
+ |
274 |
+ #ifdef RUBY_EXTERN |
275 |
+ RUBY_EXTERN const char ruby_version[]; |
276 |
+Index: marshal.c |
277 |
+=================================================================== |
278 |
+--- marshal.c (revision 34866) |
279 |
++++ marshal.c (revision 34867) |
280 |
+@@ -85,12 +85,10 @@ |
281 |
+ static ID s_getc, s_read, s_write, s_binmode; |
282 |
+ |
283 |
+ struct dump_arg { |
284 |
+- VALUE obj; |
285 |
+ VALUE str, dest; |
286 |
+ st_table *symbols; |
287 |
+ st_table *data; |
288 |
+ int taint; |
289 |
+- VALUE wrapper; |
290 |
+ }; |
291 |
+ |
292 |
+ struct dump_call_arg { |
293 |
+@@ -104,22 +102,33 @@ |
294 |
+ struct dump_arg *arg; |
295 |
+ ID sym; |
296 |
+ { |
297 |
+- if (!DATA_PTR(arg->wrapper)) { |
298 |
++ if (!arg->symbols) { |
299 |
+ rb_raise(rb_eRuntimeError, "Marshal.dump reentered at %s", |
300 |
+ rb_id2name(sym)); |
301 |
+ } |
302 |
+ } |
303 |
+ |
304 |
++static void clear_dump_arg _((struct dump_arg *arg)); |
305 |
++ |
306 |
+ static void |
307 |
+ mark_dump_arg(ptr) |
308 |
+ void *ptr; |
309 |
+ { |
310 |
+ struct dump_arg *p = ptr; |
311 |
+- if (!ptr) |
312 |
++ if (!p->symbols) |
313 |
+ return; |
314 |
+ rb_mark_set(p->data); |
315 |
++ rb_gc_mark(p->str); |
316 |
+ } |
317 |
+ |
318 |
++static void |
319 |
++free_dump_arg(ptr) |
320 |
++ void *ptr; |
321 |
++{ |
322 |
++ clear_dump_arg(ptr); |
323 |
++ xfree(ptr); |
324 |
++} |
325 |
++ |
326 |
+ static VALUE |
327 |
+ class2path(klass) |
328 |
+ VALUE klass; |
329 |
+@@ -699,32 +708,18 @@ |
330 |
+ } |
331 |
+ } |
332 |
+ |
333 |
+-static VALUE |
334 |
+-dump(arg) |
335 |
+- struct dump_call_arg *arg; |
336 |
+-{ |
337 |
+- w_object(arg->obj, arg->arg, arg->limit); |
338 |
+- if (arg->arg->dest) { |
339 |
+- rb_io_write(arg->arg->dest, arg->arg->str); |
340 |
+- rb_str_resize(arg->arg->str, 0); |
341 |
+- } |
342 |
+- return 0; |
343 |
+-} |
344 |
+- |
345 |
+-static VALUE |
346 |
+-dump_ensure(arg) |
347 |
++static void |
348 |
++clear_dump_arg(arg) |
349 |
+ struct dump_arg *arg; |
350 |
+ { |
351 |
+- if (!DATA_PTR(arg->wrapper)) return 0; |
352 |
++ if (!arg->symbols) return; |
353 |
+ st_free_table(arg->symbols); |
354 |
++ arg->symbols = 0; |
355 |
+ st_free_table(arg->data); |
356 |
+- DATA_PTR(arg->wrapper) = 0; |
357 |
+- arg->wrapper = 0; |
358 |
++ arg->data = 0; |
359 |
+ if (arg->taint) { |
360 |
+ OBJ_TAINT(arg->str); |
361 |
+ } |
362 |
+- |
363 |
+- return 0; |
364 |
+ } |
365 |
+ |
366 |
+ /* |
367 |
+@@ -760,8 +755,8 @@ |
368 |
+ { |
369 |
+ VALUE obj, port, a1, a2; |
370 |
+ int limit = -1; |
371 |
+- struct dump_arg arg; |
372 |
+- struct dump_call_arg c_arg; |
373 |
++ struct dump_arg *arg; |
374 |
++ VALUE wrapper; |
375 |
+ |
376 |
+ port = Qnil; |
377 |
+ rb_scan_args(argc, argv, "12", &obj, &a1, &a2); |
378 |
+@@ -775,37 +770,40 @@ |
379 |
+ else if (NIL_P(a1)) goto type_error; |
380 |
+ else port = a1; |
381 |
+ } |
382 |
+- arg.dest = 0; |
383 |
+- arg.symbols = st_init_numtable(); |
384 |
+- arg.data = st_init_numtable(); |
385 |
+- arg.taint = Qfalse; |
386 |
+- arg.str = rb_str_buf_new(0); |
387 |
+- RBASIC(arg.str)->klass = 0; |
388 |
+- arg.wrapper = Data_Wrap_Struct(rb_cData, mark_dump_arg, 0, &arg); |
389 |
++ wrapper = Data_Make_Struct(rb_cData, struct dump_arg, mark_dump_arg, free_dump_arg, arg); |
390 |
++ arg->dest = 0; |
391 |
++ arg->symbols = st_init_numtable(); |
392 |
++ arg->data = st_init_numtable(); |
393 |
++ arg->taint = Qfalse; |
394 |
++ arg->str = rb_str_buf_new(0); |
395 |
++ RBASIC(arg->str)->klass = 0; |
396 |
+ if (!NIL_P(port)) { |
397 |
+ if (!rb_respond_to(port, s_write)) { |
398 |
+ type_error: |
399 |
+ rb_raise(rb_eTypeError, "instance of IO needed"); |
400 |
+ } |
401 |
+- arg.dest = port; |
402 |
++ arg->dest = port; |
403 |
+ if (rb_respond_to(port, s_binmode)) { |
404 |
+ rb_funcall2(port, s_binmode, 0, 0); |
405 |
+- check_dump_arg(&arg, s_binmode); |
406 |
++ check_dump_arg(arg, s_binmode); |
407 |
+ } |
408 |
+ } |
409 |
+ else { |
410 |
+- port = arg.str; |
411 |
++ port = arg->str; |
412 |
+ } |
413 |
+ |
414 |
+- c_arg.obj = obj; |
415 |
+- c_arg.arg = &arg; |
416 |
+- c_arg.limit = limit; |
417 |
++ w_byte(MARSHAL_MAJOR, arg); |
418 |
++ w_byte(MARSHAL_MINOR, arg); |
419 |
+ |
420 |
+- w_byte(MARSHAL_MAJOR, &arg); |
421 |
+- w_byte(MARSHAL_MINOR, &arg); |
422 |
++ w_object(obj, arg, limit); |
423 |
++ if (arg->dest) { |
424 |
++ rb_io_write(arg->dest, arg->str); |
425 |
++ rb_str_resize(arg->str, 0); |
426 |
++ } |
427 |
+ |
428 |
+- rb_ensure(dump, (VALUE)&c_arg, dump_ensure, (VALUE)&arg); |
429 |
+- RBASIC(arg.str)->klass = rb_cString; |
430 |
++ RBASIC(arg->str)->klass = rb_cString; |
431 |
++ clear_dump_arg(arg); |
432 |
++ RB_GC_GUARD(wrapper); |
433 |
+ |
434 |
+ return port; |
435 |
+ } |
436 |
+@@ -817,7 +815,6 @@ |
437 |
+ st_table *data; |
438 |
+ VALUE proc; |
439 |
+ int taint; |
440 |
+- VALUE wrapper; |
441 |
+ }; |
442 |
+ |
443 |
+ static void |
444 |
+@@ -825,22 +822,31 @@ |
445 |
+ struct load_arg *arg; |
446 |
+ ID sym; |
447 |
+ { |
448 |
+- if (!DATA_PTR(arg->wrapper)) { |
449 |
++ if (!arg->symbols) { |
450 |
+ rb_raise(rb_eRuntimeError, "Marshal.load reentered at %s", |
451 |
+ rb_id2name(sym)); |
452 |
+ } |
453 |
+ } |
454 |
+ |
455 |
++static void clear_load_arg _((struct load_arg *arg)); |
456 |
++ |
457 |
+ static void |
458 |
+ mark_load_arg(ptr) |
459 |
+ void *ptr; |
460 |
+ { |
461 |
+ struct load_arg *p = ptr; |
462 |
+- if (!ptr) |
463 |
++ if (!p->symbols) |
464 |
+ return; |
465 |
+ rb_mark_tbl(p->data); |
466 |
+ } |
467 |
+ |
468 |
++static void |
469 |
++free_load_arg(void *ptr) |
470 |
++{ |
471 |
++ clear_load_arg(ptr); |
472 |
++ xfree(ptr); |
473 |
++} |
474 |
++ |
475 |
+ static VALUE r_object _((struct load_arg *arg)); |
476 |
+ |
477 |
+ static int |
478 |
+@@ -1415,23 +1421,15 @@ |
479 |
+ return r_object0(arg, arg->proc, 0, Qnil); |
480 |
+ } |
481 |
+ |
482 |
+-static VALUE |
483 |
+-load(arg) |
484 |
++static void |
485 |
++clear_load_arg(arg) |
486 |
+ struct load_arg *arg; |
487 |
+ { |
488 |
+- return r_object(arg); |
489 |
+-} |
490 |
+- |
491 |
+-static VALUE |
492 |
+-load_ensure(arg) |
493 |
+- struct load_arg *arg; |
494 |
+-{ |
495 |
+- if (!DATA_PTR(arg->wrapper)) return 0; |
496 |
++ if (!arg->symbols) return; |
497 |
+ st_free_table(arg->symbols); |
498 |
++ arg->symbols = 0; |
499 |
+ st_free_table(arg->data); |
500 |
+- DATA_PTR(arg->wrapper) = 0; |
501 |
+- arg->wrapper = 0; |
502 |
+- return 0; |
503 |
++ arg->data = 0; |
504 |
+ } |
505 |
+ |
506 |
+ /* |
507 |
+@@ -1452,8 +1450,8 @@ |
508 |
+ { |
509 |
+ VALUE port, proc; |
510 |
+ int major, minor, taint = Qfalse; |
511 |
+- VALUE v; |
512 |
+- struct load_arg arg; |
513 |
++ VALUE v, wrapper; |
514 |
++ struct load_arg *arg; |
515 |
+ |
516 |
+ rb_scan_args(argc, argv, "11", &port, &proc); |
517 |
+ v = rb_check_string_type(port); |
518 |
+@@ -1470,17 +1468,18 @@ |
519 |
+ else { |
520 |
+ rb_raise(rb_eTypeError, "instance of IO needed"); |
521 |
+ } |
522 |
+- arg.src = port; |
523 |
+- arg.offset = 0; |
524 |
+- arg.symbols = st_init_numtable(); |
525 |
+- arg.data = st_init_numtable(); |
526 |
+- arg.proc = 0; |
527 |
+- arg.wrapper = Data_Wrap_Struct(rb_cData, mark_load_arg, 0, &arg); |
528 |
+- arg.taint = taint; |
529 |
++ wrapper = Data_Make_Struct(rb_cData, struct load_arg, mark_load_arg, free_load_arg, arg); |
530 |
++ arg->src = port; |
531 |
++ arg->offset = 0; |
532 |
++ arg->symbols = st_init_numtable(); |
533 |
++ arg->data = st_init_numtable(); |
534 |
++ arg->proc = 0; |
535 |
++ arg->taint = taint; |
536 |
+ |
537 |
+- major = r_byte(&arg); |
538 |
+- minor = r_byte(&arg); |
539 |
++ major = r_byte(arg); |
540 |
++ minor = r_byte(arg); |
541 |
+ if (major != MARSHAL_MAJOR || minor > MARSHAL_MINOR) { |
542 |
++ clear_load_arg(arg); |
543 |
+ rb_raise(rb_eTypeError, "incompatible marshal file format (can't be read)\n\ |
544 |
+ \tformat version %d.%d required; %d.%d given", |
545 |
+ MARSHAL_MAJOR, MARSHAL_MINOR, major, minor); |
546 |
+@@ -1491,8 +1490,10 @@ |
547 |
+ MARSHAL_MAJOR, MARSHAL_MINOR, major, minor); |
548 |
+ } |
549 |
+ |
550 |
+- if (!NIL_P(proc)) arg.proc = proc; |
551 |
+- v = rb_ensure(load, (VALUE)&arg, load_ensure, (VALUE)&arg); |
552 |
++ if (!NIL_P(proc)) arg->proc = proc; |
553 |
++ v = r_object(arg); |
554 |
++ clear_load_arg(arg); |
555 |
++ RB_GC_GUARD(wrapper); |
556 |
+ |
557 |
+ return v; |
558 |
+ } |
559 |
+Index: test/ruby/test_marshal.rb |
560 |
+=================================================================== |
561 |
+--- test/ruby/test_marshal.rb (revision 34866) |
562 |
++++ test/ruby/test_marshal.rb (revision 34867) |
563 |
+@@ -72,6 +72,34 @@ |
564 |
+ assert_equal("marshal data too short", e.message) |
565 |
+ end |
566 |
+ |
567 |
++ class DumpTest |
568 |
++ def marshal_dump |
569 |
++ loop { Thread.pass } |
570 |
++ end |
571 |
++ end |
572 |
++ |
573 |
++ class LoadTest |
574 |
++ def marshal_dump |
575 |
++ nil |
576 |
++ end |
577 |
++ def marshal_load(obj) |
578 |
++ loop { Thread.pass } |
579 |
++ end |
580 |
++ end |
581 |
++ |
582 |
++ def test_context_switch |
583 |
++ o = DumpTest.new |
584 |
++ Thread.new { Marshal.dump(o) } |
585 |
++ GC.start |
586 |
++ assert(true, '[ruby-dev:39425]') |
587 |
++ |
588 |
++ o = LoadTest.new |
589 |
++ m = Marshal.dump(o) |
590 |
++ Thread.new { Marshal.load(m) } |
591 |
++ GC.start |
592 |
++ assert(true, '[ruby-dev:39425]') |
593 |
++ end |
594 |
++ |
595 |
+ def test_taint |
596 |
+ x = Object.new |
597 |
+ x.taint |
598 |
|
599 |
diff --git a/patchsets/patches-1.8.7_p358/series b/patchsets/patches-1.8.7_p358/series |
600 |
new file mode 100644 |
601 |
index 0000000..fb2c173 |
602 |
--- /dev/null |
603 |
+++ b/patchsets/patches-1.8.7_p358/series |
604 |
@@ -0,0 +1,7 @@ |
605 |
+001_memory_leak.patch |
606 |
+003_mkmf-parallel-install.patch |
607 |
+004_berkdb-5.0.patch |
608 |
+007_no-undefined-ext.patch |
609 |
+008_ppc64.patch |
610 |
+013_CVE-2011-0188.patch |
611 |
+014_marshall-bug.patch |