Return to BSD News archive
Newsgroups: comp.os.386bsd.bugs Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!sgi!rhyolite.wpd.sgi.com!calcite!vjs From: vjs@calcite.rhyolite.com (Vernon Schryver) Subject: Re: mktemp() crashes References: <1993Oct21.120854.2900@zen.void.oz.au>> <JKH.93Oct25234522@whisker.lotus.ie> <1993Oct27.125403.15527@zen.void.oz.au> Organization: Rhyolite Software Date: Thu, 28 Oct 1993 01:41:33 GMT Message-ID: <CFL3DA.9n8@calcite.rhyolite.com> Lines: 39 In article <1993Oct27.125403.15527@zen.void.oz.au> sjg@zen.void.oz.au (Simon J. Gerraty) writes: >... > for (i = 0; i < 10; i++) > puts(mktemp("/tmp/fooXXXXXXX")); >or > strcpy(buf, "/tmp/fooXXXXXXX"); > for (i = 0; i < 10; i++) > puts(mktemp(buf)); > >to print the same string 10 times. Likely? > >Since jkh@whisker.lotus.ie (Jordan K. Hubbard) also wrote: >>... You don't write on string constants - no no no, plain and simple! > >The first can't be what jkh was refering to as he never writes on >string constants and the 2nd even looks silly so he probably wouldn't >do that either. > >So jkh is not likely to get any unexpected result from mktemp() before >or after applying the patch. So what is he talking about? Maybe jkh would instead write something like: char buf[] = "/tmp/fooXXXXXX"; puts(mktmp(buf)); Jkh is right. Fix the junk code that does mktmp("/tmp/fooXXXXX") right, not by adding a kludge to the system. The static buffers in many other library functions have caused vast numbers of simple bugs, as we have all no doubt learned the hard way, fixing other people's naive or junk code. Worse, hidden state inside library functions are incredibly nasty problems on multiprocessors with shared-memory processes, in other words about any multiprocessor with anything called "threads." Such static kludges also cause bad problems on about any uniprocessor with threads with preemptive scheduling. Vernon Schryver vjs@rhyolite.com