Article View: comp.unix.programmer
Article #3561Re: crashes on char[]
From: cal
Date: Fri, 18 Jan 2002 20:29
Date: Fri, 18 Jan 2002 20:29
59 lines
3175 bytes
3175 bytes
It is a large project so can really post the whole program. But it is a
multi threaded program. May be I passed a wrong options to the compiler.
I use gcc 302 with the
option -D_REENTRANT -D_THREAD_SAFE -D_POSIX_C_SOURCE=199506L then link
with -lpthread. Is the option correct? And there is no -mt on HP11..........
Thanks for the help
"Barry Margolin" <barmar@genuity.net> wrote in message
news:CQI18.21$Gk3.27088@burlma1-snr2...
> In article <QeH18.95370$Z2.1353672@nnrp1.uunet.ca>,
> cal <ccheng@cybermation.com> wrote:
> >
> >Hi there,
> >
> >char asc[36864];
> >struct tm* localTime = new tm();
> >time(&timer);
> >localtime_r(&timer,localTime);
> >asctime_r(localTime, asc);
> >time_date = strdup(asc);
> >time_date[strlen(time_date) - 1] = '\0';
> >
> >or
> >
> >byte data[16384];
> >for(long offs = element.offset; offs < length; )
> >{
> > int cbRead = read(fileRead, data, 16384);
> > if(cbRead <= 0)
> > {
> > break;
> > }
> > offs = offs + cbRead;
> > write(fileWrite, data, cbRead);
> > }
> >
> >It crashes whenever I use array....... It is ok on SUN but when I port to
> >HP, the problem comes out........
>
> Are those arrays global or automatic?
>
> Your original post said that this is a multi-threaded program. If you're
> using the same global array in multiple threads, and don't have a mutex to
> mediate access to it, you can have problems.
>
> Another thing is that some architectures have a limit on the size of a
> stack frame, so you can't have huge automatic arrays. But I would expect
> the compiler to complain if you were exceeding the limits.
>
> Can you post a simple, complete example program (with main() and
> everything) that has this problem?
>
> --
> Barry Margolin, barmar@genuity.net
> Genuity, Woburn, MA
> *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to
newsgroups.
> Please DON'T copy followups to me -- I'll assume it wasn't posted to the
group.
Technical Details
Message-ID:
<ZA%18.95853$Z2.1361435@nnrp1.uunet.ca>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sunqbc.risq.qc.ca!news.uunet.ca!nnrp1.uunet.ca.POSTED!not-for-mailReferences:
<mqG18.95347$Z2.1353132@nnrp1.uunet.ca> <xKG18.7544$tg4.94829@vixen.cso.uiuc.edu> <QeH18.95370$Z2.1353672@nnrp1.uunet.ca> <CQI18.21$Gk3.27088@burlma1-snr2>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,577607e3d4dd254d X-Google-Attributes: gid11318c,public X-Google-Thread: fc89c,577607e3d4dd254d X-Google-Attributes: gidfc89c,public X-Google-ArrivalTime: 2002-01-18 12:29:46 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sunqbc.risq.qc.ca!news.uunet.ca!nnrp1.uunet.ca.POSTED!not-for-mail From: "cal" <ccheng@cybermation.com> Newsgroups: comp.unix.programmer,gnu.gcc.help References: <mqG18.95347$Z2.1353132@nnrp1.uunet.ca> <xKG18.7544$tg4.94829@vixen.cso.uiuc.edu> <QeH18.95370$Z2.1353672@nnrp1.uunet.ca> <CQI18.21$Gk3.27088@burlma1-snr2> Subject: Re: crashes on char[] Lines: 61 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: <ZA%18.95853$Z2.1361435@nnrp1.uunet.ca> Date: Fri, 18 Jan 2002 15:29:38 -0500 NNTP-Posting-Host: 209.167.133.22 X-Trace: nnrp1.uunet.ca 1011385785 209.167.133.22 (Fri, 18 Jan 2002 15:29:45 EST) NNTP-Posting-Date: Fri, 18 Jan 2002 15:29:45 EST Organization: UUNET Canada News Reader Service