From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: is+guile@kaidea.freeserve.co.uk (I.Sheldon) Newsgroups: gmane.lisp.guile.bugs Subject: [PATCH] reducing uninitialized memory warnings Date: Tue, 24 Sep 2002 19:10:52 +0100 Sender: bug-guile-admin@gnu.org Message-ID: Reply-To: is+guile@kaidea.freeserve.co.uk NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1032890942 22696 127.0.0.1 (24 Sep 2002 18:09:02 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 24 Sep 2002 18:09:02 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17tu7I-0005tf-00 for ; Tue, 24 Sep 2002 20:09:00 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17tu7O-00070o-00; Tue, 24 Sep 2002 14:09:06 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17tu79-00070E-00 for bug-guile@gnu.org; Tue, 24 Sep 2002 14:08:51 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17tu77-0006zz-00 for bug-guile@gnu.org; Tue, 24 Sep 2002 14:08:50 -0400 Original-Received: from cmailm4.svr.pol.co.uk ([195.92.193.211]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17tu76-0006zt-00 for bug-guile@gnu.org; Tue, 24 Sep 2002 14:08:49 -0400 Original-Received: from modem-3153.chimpanzee.dialup.pol.co.uk ([217.134.124.81] helo=seth.kaidea.freeserve.co.uk) by cmailm4.svr.pol.co.uk with esmtp (Exim 3.35 #1) id 17tu73-0006O6-00; Tue, 24 Sep 2002 19:08:46 +0100 Original-Received: from seth.kaidea.freeserve.co.uk (localhost.localdomain [127.0.0.1]) by seth.kaidea.freeserve.co.uk (Postfix) with ESMTP id 1EFB436AD2; Tue, 24 Sep 2002 19:10:52 +0100 (BST) Original-To: bug-guile@gnu.org X-Disclaimer: Opinions expressed are not necessarily those of me or my employers and are non-binding Original-Lines: 134 User-Agent: Gnus/5.090005 (Oort Gnus v0.05) XEmacs/21.4 (Common Lisp, i386-mandrake-linux) Errors-To: bug-guile-admin@gnu.org X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Bug reports for GUILE, GNU's Ubiquitous Extension Language List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.bugs:478 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.bugs:478 When embedding guile I noticed there were quite a few uninitialized memory read problems if it's run with a memory checker (e.g., purify, valgrind, etc.) I imagine most of these are fine, e.g., just due to holes in structures. However, for me, it would be better to reduce these so when guile is embedded, developers don't see warnings due to guile. The following patch helps eliminate some of these warnings. With a simple test of starting guile and then typing `(quit)', this reduced the number of warnings I was getting from 19270 to 19014. It does this by ensuring the jmp_buf is fully initialized since, otherwise, functions such as scm_mark_locations used to complain more frequently (e.g., jmpbuf saved in coop-threads.c, then an scm_mark_locations for each short for sizeof the jmpbuf struct, so with holes in the structure it meant several read warnings). * continuations.c ("scm_make_continuation"): added memset for jmpbuf to reduce uninitialized memory warnings. * coop-threads.c ("scm_threads_mark_stacks"): ditto * gc-mark.c ("scm_mark_all"): ditto * gc_os_dep.c ("GC_reset_fault_handler"): ditto * throw.c ("scm_internal_catch"): ditto Hope it's useful, Ian. Index: continuations.c =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/continuations.c,v retrieving revision 1.45 diff -u -r1.45 continuations.c --- continuations.c 4 Aug 2002 00:17:18 -0000 1.45 +++ continuations.c 24 Sep 2002 17:17:54 -0000 @@ -190,6 +190,7 @@ return ret; } #else /* !__ia64__ */ + memset (&continuation->jmpbuf, 0, sizeof continuation->jmpbuf); if (setjmp (continuation->jmpbuf)) { SCM ret = continuation->throw_value; Index: coop-threads.c =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/coop-threads.c,v retrieving revision 1.35 diff -u -r1.35 coop-threads.c --- coop-threads.c 1 Mar 2002 00:19:20 -0000 1.35 +++ coop-threads.c 24 Sep 2002 17:17:56 -0000 @@ -46,6 +46,10 @@ #include "libguile/coop-threads.h" #include "libguile/root.h" +#ifdef HAVE_STRING_H +#include +#endif + /* A counter of the current number of threads */ size_t scm_thread_count = 0; @@ -105,6 +109,7 @@ */ SCM_FLUSH_REGISTER_WINDOWS; /* This assumes that all registers are saved into the jmp_buf */ + memset (&scm_save_regs_gc_mark, 0, sizeof scm_save_regs_gc_mark); setjmp (scm_save_regs_gc_mark); scm_mark_locations ((SCM_STACKITEM *) scm_save_regs_gc_mark, ((size_t) sizeof scm_save_regs_gc_mark @@ -126,6 +131,7 @@ */ SCM_FLUSH_REGISTER_WINDOWS; /* This assumes that all registers are saved into the jmp_buf */ + memset (&scm_save_regs_gc_mark, 0, sizeof scm_save_regs_gc_mark); setjmp (scm_save_regs_gc_mark); scm_mark_locations ((SCM_STACKITEM *) scm_save_regs_gc_mark, ((size_t) sizeof scm_save_regs_gc_mark Index: gc-mark.c =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/gc-mark.c,v retrieving revision 1.4 diff -u -r1.4 gc-mark.c --- gc-mark.c 8 Aug 2002 23:18:23 -0000 1.4 +++ gc-mark.c 24 Sep 2002 17:17:59 -0000 @@ -115,6 +115,7 @@ /* Mark objects on the C stack. */ SCM_FLUSH_REGISTER_WINDOWS; /* This assumes that all registers are saved into the jmp_buf */ + memset (&scm_save_regs_gc_mark, 0, sizeof scm_save_regs_gc_mark); setjmp (scm_save_regs_gc_mark); scm_mark_locations ((SCM_STACKITEM *) scm_save_regs_gc_mark, ( (size_t) (sizeof (SCM_STACKITEM) - 1 + Index: gc_os_dep.c =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/gc_os_dep.c,v retrieving revision 1.13 diff -u -r1.13 gc_os_dep.c --- gc_os_dep.c 8 Jul 2002 23:41:00 -0000 1.13 +++ gc_os_dep.c 24 Sep 2002 17:18:07 -0000 @@ -1758,6 +1758,7 @@ GC_setup_temporary_fault_handler(); + memset (&GC_jmp_buf, 0, sizeof GC_jmp_buf); if (setjmp(GC_jmp_buf) == 0) { result = (ptr_t)(((word)(p)) & ~(MIN_PAGE_SIZE-1)); Index: throw.c =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/throw.c,v retrieving revision 1.91 diff -u -r1.91 throw.c --- throw.c 20 Jul 2002 14:08:34 -0000 1.91 +++ throw.c 24 Sep 2002 17:18:10 -0000 @@ -63,6 +63,10 @@ #include "libguile/validate.h" #include "libguile/throw.h" +#ifdef HAVE_STRING_H +#include +#endif + /* the jump buffer data structure */ static scm_t_bits tc16_jmpbuffer; @@ -182,6 +186,7 @@ #ifdef DEBUG_EXTENSIONS SCM_SETJBDFRAME(jmpbuf, scm_last_debug_frame); #endif + memset (&jbr.buf, 0, sizeof jbr.buf); if (setjmp (jbr.buf)) { SCM throw_tag; _______________________________________________ Bug-guile mailing list Bug-guile@gnu.org http://mail.gnu.org/mailman/listinfo/bug-guile