Re: SEGV in TGMimeTypes on SunOS 5.6

From: Fons Rademakers (rdm@pcsalo.cern.ch)
Date: Tue Aug 24 1999 - 22:54:44 MEST


Hi Eddy,

   we just fixed the problem (it was a few days ago reported by another 
user using purify). Anyway, many thanks for tracing this problem. The
more people using Purify the better the program will get.

Cheers, Fons.


PS: it was a clear bug, not a compiler issue. Your fix is ok.


> 
> Running on "SunOS 5.6 Generic_105181-11 sun4u sparc SUNW,Ultra-Enterprise"
> and using CC compiler : CC: SC4.0 18 Oct 1995 C++ 4.1
> 
> My program uses the ROOT libraries but has its own main
> as described in the TROOT class. When distributing it to other machines
> I noticed that it SEGV-ed there. Running "purify" revealed the following:
> 
> --------------------------
> ****  Purify instrumented RenRoot (pid 1985 at Tue Aug 24 15:13:47 1999)
>   * Purify 4.2 Solaris 2, Copyright (C) 1992-1998 Rational Software Corp. All rights reserved.
>   * For contact information type: "purify -help"
>   * Command-line: RenRoot
>   * Options settings: -purify -logfile=./purify_report.%v.%p -first-only \
>     -purify-home=/usr/local/pure/purify-4.2-solaris2
> 
> ****  Purify instrumented RenRoot (pid 1985)  ****
> FMR: Free memory read:
>   * This is occurring while in:
>         strncmp        [rtlib.o]
>         TGMimeTypes::TGMimeTypes(TGClient*, const char*) [GUI_GMimeTypes.cxx:58]
>         TGClient::TGClient(const char*) [libGui.so]
>         TRootApplication::TRootApplication(const char*, int*, char**, void*, int) [libGui.so]
>         TRootGuiFactory::CreateApplicationImp(const char*, int*, char**, void*, int) [libGui.so]
>         TApplication::TApplication(const char*, int*, char**, void*, int) [libBase.so]
>   * Reading 1 byte from 0x5dfa00 in the heap.
>   * Address 0x5dfa00 is 8 bytes into a freed  block at 0x5df9f8 of 17 bytes.
>   * This block was allocated from:
>         malloc         [rtlib.o]
>         calloc         [rtlib.o]
>         __0OnWuI       [libNew.so]
>         operator new(unsigned int) [rtlib.o]
>         Strip(const char*) [libBase.so]
>         TGMimeTypes::TGMimeTypes(TGClient*, const char*) [GUI_GMimeTypes.cxx:58]
>   * There have been 0 frees since this block was freed from:
>         free           [rtlib.o]
>         __0OdLpV       [libNew.so]
>         operator delete(void*) [rtlib.o]
>         TGMimeTypes::TGMimeTypes(TGClient*, const char*) [GUI_GMimeTypes.cxx:58]
>         TGClient::TGClient(const char*) [libGui.so]
>         TRootApplication::TRootApplication(const char*, int*, char**, void*, int) [libGui.so]
> --------------------------
> 
> Looking in GUI_GMimeTypes.cxx, I could only think of a compiler  confused (or purify)
> by the lines "s = Strip(s)". Replacing them, solved indeed the purify problem
> and the segmentation violation !!
> 
> GUI_GMimeTypes.cxx:
> --------------------
>       if (!strncmp(s, "pattern", 7)) {
>          if (!(s = strchr(line, '='))) {
>             Error("TGMimeTypes", "malformed pattern line, = missing");
>             pattern[0] = 0;
>          } else {
>             s++;
>             //s = Strip(s);
>             //strcpy(pattern, s);
>             //delete [] s;
>             tmp = Strip(s);
>             strcpy(pattern, tmp);
>             delete [] tmp;
>          }
>          cnt++;
>       }
>       if (!strncmp(s, "icon", 4)) {
>          if (!(s = strchr(line, '='))) {
>             Error("TGMimeTypes", "malformed icon line, = missing");
>             icon[0] = 0;
>          } else {
>             s++;
>             //s = Strip(s);
>             //strcpy(icon, s);
>             //delete [] s;
>             tmp = Strip(s);
>             strcpy(icon, tmp);
>             delete [] tmp;
>          }
>          cnt++;
>       }
>       if (!strncmp(s, "action", 6)) {
>          if (!(s = strchr(line, '='))) {
>             Error("TGMimeTypes", "malformed action line, = missing");
>             action[0] = 0;
>          } else {
>             s++;
>             //s = Strip(s);
>             //strcpy(action, s);
>             //delete [] s;
>             tmp = Strip(s);
>             strcpy(action, tmp);
>             delete [] tmp;
>          }
>          cnt++;
>       }
> 
> This issue is maybe resolved in CC 5.0 but it is not straightforward to
> compile ROOT under CC 5.0 (more has to be done than just make).
> 
> Best Regards, Eddy
> 


-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7677910



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:38 MET