TOP
SSV Software Systems Register  Register
Log in to check your private messages  Log in to check your private messages
Startseite FAQ Search Mitglieder Profile  Log in 
SSV Support-Forum
Laufzeitfehler durch Stack Overflow ...

 
Post new topic   Reply to topic    SSV-Forum Forum Index >>> IGW/800
<<< Previous topic - Next topic >>>  
Display posts from previous:   
Author Message
kdw



Joined: 05 May 2006
Posts: 1460

PostPosted: 30.01.2008, 12:10    Post subject: Laufzeitfehler durch Stack Overflow ... Reply with quote

Hallo Forum.

Das folgende C-basierte Code-Fragment:

Code:
int main (int argc, char* argv[])
{
   int nLen= sizeof (struct sockaddr), nRet, s1;
   long lRet;
   char szBuf[1024*16], szWday[16], szMon[16];
   struct sockaddr_in saServer;
   struct tm *tmPtr;
   time_t currTime;
   :
   :
}


kann beim uClinux des DNP/5282 (das ist der Rechnerkern eines IGW/800) zu einem Laufzeitfehler führen. Ursache ist die Deklaration „szBuf[1024*16]“. Dadurch wird ein 16 KBytes großes Array erzeugt, welches im Stack des übersetzten Programms liegt. Dadurch entsteht zur Laufzeit ein Stack Overflow.

Abhilfe schafft eine globale Variable (nicht schön, aber hilfreich):

Code:
char szBuf[1024*16];

int main (int argc, char* argv[])
{
   int nLen= sizeof (struct sockaddr), nRet, s1;
   long lRet;
   char szWday[16], szMon[16];
   struct sockaddr_in saServer;
   struct tm *tmPtr;
   time_t currTime;
   :
   :
}


Dadurch liegt das 16 KBytes große Array nun im Datensegment der Anwendung.

Gruß

KDW
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SSV-Forum Forum Index >>> IGW/800 All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

SSV Software Systems GmbH

Dünenweg 5
30419 Hannover

Fon: +49(0)511  ·  40 000-0
Fax: +49(0)511  ·  40 000-40

sales@ssv-embedded.de


Impressum    ·    Datenschutz    ·    AGB

© 2023 SSV SOFTWARE SYSTEMS GmbH. Alle Rechte vorbehalten.

ISO 9001:2015