zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: Re: About zmodload test segfaults
Date: Mon, 28 May 2001 11:21:30 +0200 (MET DST)	[thread overview]
Message-ID: <200105280921.LAA06136@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: <1010523165140.ZM9483@candle.brasslantern.com>

Bart Schaefer wrote:

> ...
> 
> Please check whether this takes care of the zmodload test segfaults on
> various architectures.

That patch took care of the chatty loader under Tru64 Unix, of course.

The patch below takes care of the floating point exception I was seeing
when trying to unload the zprof module.  It makes the wrapper function
zprof registers be more careful, effectively avoiding most of the code
if the zprof module is currently being unloaded.  Which is a good thing
to do anyway.

Now I get a `all tests successful' for V01 here, too.

Bye
  Sven

Index: Src/Modules/zprof.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/zprof.c,v
retrieving revision 1.2
diff -u -r1.2 zprof.c
--- Src/Modules/zprof.c	2001/03/20 09:35:48	1.2
+++ Src/Modules/zprof.c	2001/05/28 09:17:54
@@ -68,6 +68,7 @@
 static Parc arcs;
 static int narcs;
 static Sfunc stack;
+static Module zprof_module;
 
 static void
 freepfuncs(Pfunc f)
@@ -216,6 +217,7 @@
 static int
 zprof_wrapper(Eprog prog, FuncWrap w, char *name)
 {
+    int active = 0;
     struct sfunc sf, *sp;
     Pfunc f;
     Parc a = NULL;
@@ -223,56 +225,64 @@
     struct timezone dummy;
     double prev, now;
 
-    if (!(f = findpfunc(name))) {
-	f = (Pfunc) zalloc(sizeof(*f));
-	f->name = ztrdup(name);
-	f->calls = 0;
-	f->time = f->self = 0.0;
-	f->next = calls;
-	calls = f;
-	ncalls++;
+    if (zprof_module && !(zprof_module->flags & MOD_UNLOAD)) {
+        active = 1;
+        if (!(f = findpfunc(name))) {
+            f = (Pfunc) zalloc(sizeof(*f));
+            f->name = ztrdup(name);
+            f->calls = 0;
+            f->time = f->self = 0.0;
+            f->next = calls;
+            calls = f;
+            ncalls++;
+        }
+        if (stack) {
+            if (!(a = findparc(stack->p, f))) {
+                a = (Parc) zalloc(sizeof(*a));
+                a->from = stack->p;
+                a->to = f;
+                a->calls = 0;
+                a->time = a->self = 0.0;
+                a->next = arcs;
+                arcs = a;
+                narcs++;
+            }
+        }
+        sf.prev = stack;
+        sf.p = f;
+        stack = &sf;
+
+        f->calls++;
+        tv.tv_sec = tv.tv_usec = 0;
+        gettimeofday(&tv, &dummy);
+        sf.beg = prev = ((((double) tv.tv_sec) * 1000.0) +
+                         (((double) tv.tv_usec) / 1000.0));
     }
-    if (stack) {
-	if (!(a = findparc(stack->p, f))) {
-	    a = (Parc) zalloc(sizeof(*a));
-	    a->from = stack->p;
-	    a->to = f;
-	    a->calls = 0;
-	    a->time = a->self = 0.0;
-	    a->next = arcs;
-	    arcs = a;
-	    narcs++;
-	}
-    }
-    sf.prev = stack;
-    sf.p = f;
-    stack = &sf;
-
-    f->calls++;
-    tv.tv_sec = tv.tv_usec = 0;
-    gettimeofday(&tv, &dummy);
-    sf.beg = prev = ((((double) tv.tv_sec) * 1000.0) +
-		     (((double) tv.tv_usec) / 1000.0));
     runshfunc(prog, w, name);
-    tv.tv_sec = tv.tv_usec = 0;
-    gettimeofday(&tv, &dummy);
-
-    now = ((((double) tv.tv_sec) * 1000.0) +
-	   (((double) tv.tv_usec) / 1000.0));
-    f->self += now - sf.beg;
-    for (sp = sf.prev; sp && sp->p != f; sp = sp->prev);
-    if (!sp)
-	f->time += now - prev;
-    if (a) {
-	a->calls++;
-	a->self += now - sf.beg;
-    }
-    stack = sf.prev;
-
-    if (stack) {
-	stack->beg += now - prev;
-	if (a)
-	    a->time += now - prev;
+    if (active) {
+        if (zprof_module && !(zprof_module->flags & MOD_UNLOAD)) {
+            tv.tv_sec = tv.tv_usec = 0;
+            gettimeofday(&tv, &dummy);
+
+            now = ((((double) tv.tv_sec) * 1000.0) +
+                   (((double) tv.tv_usec) / 1000.0));
+            f->self += now - sf.beg;
+            for (sp = sf.prev; sp && sp->p != f; sp = sp->prev);
+            if (!sp)
+                f->time += now - prev;
+            if (a) {
+                a->calls++;
+                a->self += now - sf.beg;
+            }
+            stack = sf.prev;
+
+            if (stack) {
+                stack->beg += now - prev;
+                if (a)
+                    a->time += now - prev;
+            }
+        } else
+            stack = sf.prev;
     }
     return 0;
 }
@@ -289,6 +299,7 @@
 int
 setup_(Module m)
 {
+    zprof_module = m;
     return 0;
 }
 

-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


  parent reply	other threads:[~2001-05-28  9:22 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-22 15:14 Almost all tests pass under new cygwin Andrej Borsenkow
2001-05-22 15:24 ` Andrej Borsenkow
2001-05-22 15:31 ` Bart Schaefer
2001-05-22 15:44   ` Oliver Kiddle
2001-05-23 16:51     ` About zmodload test segfaults Bart Schaefer
2001-05-24 12:15       ` Andrej Borsenkow
2001-05-25 16:54         ` PATCH: Block device tests Bart Schaefer
2001-05-26  8:24           ` Andrej Borsenkow
2001-05-27 22:54             ` Bart Schaefer
2001-05-28  6:50               ` Andrej Borsenkow
2001-05-28 16:06                 ` Bart Schaefer
2001-05-28 17:25                   ` Bart Schaefer
2001-05-29 10:34                   ` Peter Stephenson
2001-05-29 10:51                     ` Andrej Borsenkow
2001-05-29 15:37                       ` Bart Schaefer
2001-05-30  9:21                         ` Peter Stephenson
2001-05-28  9:21       ` Sven Wischnowsky [this message]
2001-05-22 15:53   ` Almost all tests pass under new cygwin Andrej Borsenkow
2001-05-23 11:40 ` Peter Stephenson

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=200105280921.LAA06136@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.dk \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).