This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Thread error with large buffer


4k is a lot of data to put on a stack. also note that you have 4000
bytes, not 4k there.

why not just make it static? also there are routines you can use to
check the stack size and usage for a given thread. also you can adjust
the stack size for main (the default in a kernel i just glanced at is
8k). also you can enable stack overflow checking.

-Dan

> -----Original Message-----
> From: Trenton D. Adams [mailto:tadams@extremeeng.com]
> Sent: Thursday, July 19, 2001 3:18 PM
> To: 'eCos mailing list'
> Subject: [ECOS] Thread error with large buffer
> 
> 
> I'm doing some network tests to test the things some of us 
> were talking
> about before with send sending everything before returning.  I get the
> output below.
> 
> Transfer rate: 656912 bits/sec, 306 bytes/write.
> TRACE: <4>[88]int main() This is the system-supplied default main()
> TRACE: <4>[107]void cyg_libc_invoke_main() main() has 
> returned with code
> 0. Calling exit()
> TRACE: <4>[84]void exit() Calling fflush( NULL )
> Start socket test
> ASSERT FAIL: <2>[166]static void 
> Cyg_Scheduler::unlock_inner() Bad next
> thread
> 
> 
> Below is the thread.  It doesn't give the error above if the buffer
> variable is 400.  Anyone have any ideas why this might be?  Surely a
> static buffer of 4K is not un-reasonable?
> net_test(cyg_addrword_t param)
> {
>     int s;
>     int one = 1;
>     int index;
>     struct sockaddr_in addr;
> 
>     char buffer[4000];
> 
>     buffer[0] = '\0';
> 
>     diag_printf("Start socket test\n");
>     init_all_network_interfaces();
> 
>     for (index = 0; index < 78; index++)
>     {
>         strcat (buffer, 
>             "Hello From eCos! Hello From eCos! Hello From eCos!\n");
>     }
> 
> 
>     s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
>     diag_printf("socket() = %d\n", s);
> 
>     diag_printf ("%x", inet_addr ("172.16.1.9"));
>     addr.sin_addr.s_addr = inet_addr ("172.16.1.9");
>     addr.sin_family = AF_INET;
>     addr.sin_port = htons (1024);
>     addr.sin_len = sizeof (addr);
>     if (connect (s, &addr, sizeof (addr)) != 0)
>     {
>         diag_printf ("Error connecting to socket! - %d\n", 
>             errno);
>         cyg_test_exit();
>     }
> 
>     if (send (s, buffer, strlen (buffer), 0) != 0)
>     {
>         diag_printf ("Error sending to socket! - %d\n", 
>             errno);
>         cyg_test_exit();
>     }
>         
> 
>     cyg_test_exit();
> }
> 
> Trenton D. Adams
> Embedded Developer
> Windows Developer
> Extreme Engineering Ltd.
> Calgary Alberta.
> 
> 
> 
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]