Article View: news.software.readers
Article #1026Re: mthreads problem on a 3b1
From: Rob Stampfli
Date: Sun, 12 Jan 1992 06:18
Date: Sun, 12 Jan 1992 06:18
70 lines
4765 bytes
4765 bytes
In article <1992Jan10.190520.22679@borland.com> davison@borland.com (Wayne Davison) writes: >Roger Abrahams (roger@booth.uucp) wrote: >> In my case, I have a smallish AT&T 3b1 Unix-PC box with only 2.5 megs of >> active memory and 5 megs of swap. [...] It seems that >> the mthreads program is a real hog of memory and system resources. In fact >> it will grab all the memory it can get (2.5 megs [...] > >No, mthreads doesn't need anywhere near that much memory. On our Sun it >typically expands to about 256k (which is what it is right now). There is >apparently a bug somewhere in the 3b1's compiler, support libraries, or >_something_ that is causing it to waste memory. I don't have access to a >3b1 (or 3b2, which has the same problem), so I can't check it out. Also, >none of the people who have these systems have yet been able to tell me >what their system is doing wrong, so I have not been able to provide a fix. There is something very wrong with mthreads on the 3B1. It does behave exactly like Roger says. I studied it quite intently for awhile -- it acts like it has a memory leak. Here is what I found: When it is executed, it starts out fairly small, but then continues to consume memory (at a fairly linear rate) until it hits the 3b1's limit of 2.5 Meg. It then aborts with a "malloc failure" message. Is it malloc'ing and not freeing? Not that I can tell. I wrote a special envelope for the malloc/free routines and the safemalloc/safefree counterparts that keep track of what is done. I could not detect any pointers allocated but not freed after extensive runs. Is it corrupting memory by writing before/after the malloc'ed space? I modified the envelope routines to leave an untouched 4-byte buffer on each side of any malloc'ed area and that didn't change things one bit. Is malloc hosed on the 3B1? I used both the standard as well as the -lmalloc options and they behaved identically. I even played around with the -lmalloc mallopt() parameters to no avail. I then wrote a program which randomly does malloc's and frees (of previously malloc'ed memory) -- _it_ didn't grow without bound. I also run the KA9Q net program, which was conceived around the concept of malloc/free, and it has run fine without this apparent anomaly for years. I did verify also that the malloc program really thought it *was* consuming the memory. It does, and it isn't something like a recursive function call growing the stack without end. Oh yes, no difference whether I use cc or gcc (1.39). And, no difference whether compiled with the 3B1 shared library or not. Cores (2.5 Meg ones.) show reams and reams of the same items that are in the .thread files -- Message-IDs, Subject lines, etc. I did find what I think are a couple of bugs in mthreads: There are several instances of: "safefree(article->id);" which should be "safefree(&article->id);" in mt-read.c. Changing these did not materially affect the memory leak, though. (I tried sending mail to you, Wayne, but it bounced.) I finally gave up. I only thread about 150 groups on my machine and this is not enough to cause mthreads, or the 3B1, undue hardship, provided it is invoked like Roger says. It *does* do the intended job, just consuming an ever increasing quantity of memory in the process. I would like to run it as a daemon process, though, eventually. What I didn't do was verify that something was not calling malloc() with an increasingly larger argument. Maybe I will check this if I get time. My gut feeling is that either (1) mthreads is doing something cleverly diabolical that just happens to be benign on other artitectures, or (2) malloc() and free() have an obscure bug on the 3B1 that mthreads manages to stimulate. Whichever, if anyone can shed any light on this, I would certainly like to hear about it. Well, at least this is the stuff that makes software engineering interesting... -- Rob Stampfli, 614-864-9377, res@kd8wk.uucp (osu-cis!kd8wk!res), kd8wk@n8jyv.oh
Technical Details
Message-ID:
<1992Jan12.061800.15282@colnet.uucp>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.sys.3b1.mbox.zip!sparky!uunet!usc!zaphod.mps.ohio-state.edu!n8emr!colnet!resReferences:
<1992Jan9.100907.13305@cs.tu-berlin.de> <1992Jan10.020103.3837@booth.uucp> <1992Jan10.190520.22679@borland.com>Show Full Headers
Complete Article Headers
Message-ID: <1992Jan12.061800.15282@colnet.uucp> Subject: Re: mthreads problem on a 3b1 Date: Sun, 12 Jan 1992 06:18:00 GMT From: res@colnet.uucp (Rob Stampfli) References: <1992Jan9.100907.13305@cs.tu-berlin.de> <1992Jan10.020103.3837@booth.uucp> <1992Jan10.190520.22679@borland.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.sys.3b1.mbox.zip!sparky!uunet!usc!zaphod.mps.ohio-state.edu!n8emr!colnet!res Newsgroups: news.software.b,news.software.readers,comp.sys.3b1 Organization: Little to None