changeset 5156:6bff4f219697

fix crash etc. in tests.c/c-tests.el -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-03-18 Ben Wing <ben@xemacs.org> * tests.c: * tests.c (Ftest_data_format_conversion): Need to GCPRO newly created objects or we'll eventually get a crash due to occurrence of call2(). tests/ChangeLog addition: 2010-03-18 Ben Wing <ben@xemacs.org> * automated/c-tests.el: * automated/c-tests.el (when): Use `with-temp-buffer' so results don't get written into source file.
author Ben Wing <ben@xemacs.org>
date Thu, 18 Mar 2010 10:19:08 -0500
parents c97dc3b6de63
children 1fae11d56ad2
files src/ChangeLog src/tests.c tests/ChangeLog tests/automated/c-tests.el
diffstat 4 files changed, 38 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Thu Mar 18 10:17:13 2010 -0500
+++ b/src/ChangeLog	Thu Mar 18 10:19:08 2010 -0500
@@ -1,3 +1,10 @@
+2010-03-18  Ben Wing  <ben@xemacs.org>
+
+	* tests.c:
+	* tests.c (Ftest_data_format_conversion):
+	Need to GCPRO newly created objects or we'll eventually get
+	a crash due to occurrence of call2().
+
 2010-03-15  Ben Wing  <ben@xemacs.org>
 
 	* extents.c (Fprevious_single_property_change):
--- a/src/tests.c	Thu Mar 18 10:17:13 2010 -0500
+++ b/src/tests.c	Thu Mar 18 10:19:08 2010 -0500
@@ -49,7 +49,7 @@
        ())
 {
   void *ptr; Bytecount len;
-  Lisp_Object string, opaque, conversion_result = Qnil;
+  Lisp_Object string = Qnil, opaque = Qnil, conversion_result = Qnil;
 
   Ibyte int_foo[] = "\n\nfoo\nbar";
   Extbyte ext_unix[]= "\n\nfoo\nbar";
@@ -72,6 +72,20 @@
   Lisp_Object string_latin1 = make_string (int_latin1, sizeof (int_latin1) - 1);
   int autodetect_eol_p =
     !NILP (Fsymbol_value (intern ("eol-detection-enabled-p")));
+  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
+  struct gcpro ngcpro1, ngcpro2, ngcpro3;
+#ifdef MULE
+  struct gcpro ngcpro4;
+#endif
+
+  /* DFC conversion inhibits GC, but we have a call2() below which calls
+     Lisp, which can trigger GC, so we need to GC-protect everything here. */
+  GCPRO5 (string, opaque, conversion_result, opaque_dos, string_foo);
+#ifdef MULE
+  NGCPRO4 (string_latin2, opaque_latin, opaque0_latin, string_latin1);
+#else
+  NGCPRO3 (opaque_latin, opaque0_latin, string_latin1);
+#endif
 
   /* Check for expected strings before and after conversion.
      Conversions depend on whether MULE is defined. */
@@ -541,6 +555,8 @@
 		      Qbinary);
   DFC_CHECK_DATA (ptr, len, ext_dos, "DOS Lisp opaque, ALLOCA, binary");
 
+  NUNGCPRO;
+  UNGCPRO;
   return conversion_result;
 }
 
--- a/tests/ChangeLog	Thu Mar 18 10:17:13 2010 -0500
+++ b/tests/ChangeLog	Thu Mar 18 10:19:08 2010 -0500
@@ -1,3 +1,10 @@
+2010-03-18  Ben Wing  <ben@xemacs.org>
+
+	* automated/c-tests.el:
+	* automated/c-tests.el (when):
+	Use `with-temp-buffer' so results don't get written into source
+	file.
+
 2010-03-12  Ben Wing  <ben@xemacs.org>
 
 	* automated/base64-tests.el (bt-base64-encode-string):
--- a/tests/automated/c-tests.el	Thu Mar 18 10:17:13 2010 -0500
+++ b/tests/automated/c-tests.el	Thu Mar 18 10:19:08 2010 -0500
@@ -1,4 +1,5 @@
 ;; Copyright (C) 2000 Martin Buchholz
+;; Copyright (C) 2010 Ben Wing.
 
 ;; Author: Martin Buchholz <martin@xemacs.org>
 ;; Maintainer: Martin Buchholz <martin@xemacs.org>
@@ -38,8 +39,9 @@
        (push (file-name-directory load-file-name) load-path))
      (require 'test-harness))))
 
-(when (boundp 'test-function-list)	; Only if configure --debug
-  (loop for fun in test-function-list do
-    ;; #### I hope there's no way we can signal ...
-    (loop for result in (funcall fun) do
-      (Assert (nth 1 result) (nth 2 result) (nth 0 result)))))
+(with-temp-buffer
+    (when (boundp 'test-function-list)	; Only if configure --debug
+      (loop for fun in test-function-list do
+	;; #### I hope there's no way we can signal ...
+	(loop for result in (funcall fun) do
+	  (Assert (nth 1 result) (nth 2 result) (nth 0 result))))))