🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3567

Re: crashes on char[]

#3567
From: Barry Margolin
Date: Thu, 17 Jan 2002 23:09
48 lines
2803 bytes
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: <CQI18.21$Gk3.27088@burlma1-snr2>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!news.gtei.net!burlma1-snr2!53ab2750!not-for-mail
References: <mqG18.95347$Z2.1353132@nnrp1.uunet.ca> <xKG18.7544$tg4.94829@vixen.cso.uiuc.edu> <QeH18.95370$Z2.1353672@nnrp1.uunet.ca>

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-17 15:09:24 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!news.gtei.net!burlma1-snr2!53ab2750!not-for-mail
From: Barry Margolin <barmar@genuity.net>
Newsgroups: comp.unix.programmer,gnu.gcc.help
Subject: Re: crashes on char[]
References: <mqG18.95347$Z2.1353132@nnrp1.uunet.ca> <xKG18.7544$tg4.94829@vixen.cso.uiuc.edu> <QeH18.95370$Z2.1353672@nnrp1.uunet.ca>
Organization: Genuity, Cambridge, MA
Mail-Copies-To: never
X-Newsreader: trn 4.0-test72 (19 April 1999)
Originator: barmar@genuity.net (Barry Margolin)
Lines: 48
Message-ID: <CQI18.21$Gk3.27088@burlma1-snr2>
X-Trace: +rUPLu+TK5uLTT/vDotES78cN76DrFmqPYwkWSuhuJLljvx/Pe1kQXYqrHw9a5NeYUk/I9J6akRJ!x17SMwEQiv+zLZtDLZ0E3bJ/ejvDF7A6eY9ijpojCyv2gQW/PhyJ0vnLmLGSBJK+w7c=
X-Complaints-To: abuse@genuity.net
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly
NNTP-Posting-Date: Thu, 17 Jan 2002 23:09:22 GMT
Distribution: world
Date: Thu, 17 Jan 2002 23:09:22 GMT