On Friday 15 November 2002 08:09, you wrote: > > I have a feeling that the answer to my segfault problems has been > sitting in front of my nose all along. To recap, I have a vendor
It is sometimes so, yes... This can drive you mad for some time :( > library, of unknown thread-safe-ness, which I'm using in an AOLserver > loadable module. Despite serializing all access to the vendor library > with a mutex, I still occasionaly get weird segfaults in _smalloc, > nasty Purify errors, and occasional other weird behavior. All > symptoms point to heap corruption. > > Turns out, *ALL* the Array Bounds Write, Free Memory Write and Read, > and other nasty Purify errors (aka, not just UMR) are from the "tzcpy" > function, which is called ultimately from localtime_u, localtime_r, > mktime, or strftime. The way some of the *_r functions are implemented is that they employ internal mutex to serialize access. This, of course, defeats your approach entirely (but read below...) > > Does the TZ env array issue occur anywhere else in AOLserver or Tcl, > or are there any other non-thread-safe library calls I should bee > looking out for? You should not be using thread unsafe functions. Period. I know it does not help much in your case, but this is the bottom line. But, in this case, you should try modifying the thread/reentrant.c and lock the same mutex for localtime_r() in ns_localtime(). > > (If I had a good list of all non-thread safe library calls, maybe I > could run a truss on everything to everywhere they're being used...) > I have compiled the list of all such functions but I can't find it now. I'm sure my collegue has it but he's away from office until monday. If I dig it out, I can send it to you. Cheers, Zoran
