| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | trap 0005 |
Hallo Henk!
Am 16.03.97 schrieb Henk den Adel folgendes zum Thema "trap 0005" an All:
/snip/
HdA> The reason for this message is a struct, which is 40 kB in size.
This tends to be dangerous... as you found out.
HdA> When i changed:
HdA> struct desc heads;
HdA> into:
HdA> static struct desc heads;
HdA> problems are solved under OS/2 and DOS; the reason probably is that
HdA> the struct is placed in the data segment.
Yes.
HdA> The same result (under OS/2 and DOS) could be achieved when static is
HdA> omitted when simultaneously the stack size was enlarged to
HdA> STACK:50000.
Right.
HdA> I would appreciate if anyone could explain me why the stack is not
HdA> automatically chosen to be sufficiently large, or better how to
HdA> order the compiler to choose the right stack size. I'm using ibm's C
HdA> compiler, version 2.01.
With that one, default stack size is 8k, if I remember correctly. As your
struct is larger, there is obviously a problem. But a compiler can never be
sure how much stack is needed, because that depends on runtime behaviour (a
recursivly called routine will use up as much stack space as it wants,
depending on the depth of the recursion). So there is _no_ way a compiler
can choose the "right" stack size.
Some OS give you a huge amount of stack, that isn't really committed until
the application actually uses it. Although it _is_ possible to use such a
mechanism under OS/2 (look into your compiler doc under the key word
"stack probes"), this will not help you under DOS and similar
environments without decent memory management.
General rule of thumb: don't put objects larger than, say, 1k onto the
stack. Instead, get them from the heap by malloc/free. Especially do this
in libraries which normally will use the stack of the calling application.
As the user of the library will not normally suspect huge stack demands,
your library will be made responsible for the problems that arise.
Hope this helps,
Klaus
Disclaimer: The opinions expressed are solely those of the author.
And are most probably wrong anyway.
--- FleetStreet 1.18+
* Origin: Paradatec (2:241/550.40)SEEN-BY: 50/99 54/99 270/101 620/243 625/155 711/401 413 430 934 712/311 407 SEEN-BY: 712/505 506 517 623 624 704 713/317 800/1 @PATH: 241/550 500 1000 2448/600 24/888 396/1 270/101 712/624 711/934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.