2010-07-22 09:55:51 application crash when there are many environment variables
Timur Aydin (TURKEY)
Message: 91585
I am defining about 90 environment variables in /etc/profile. The variable names are in average 20 characters long and their values are in averate 10 characters long. When the system boots, one of my executables run and that executable does a "getenv" to retrieve the value of an environment variable. This immediately causes uclinux to crash. The crash is either a SIGSEGV or a BUS ERROR. If I reduce the number of environment variables with no other change, the problem goes away.
I have tested this with both uclinux_2008R1.5 and with the git trunk version.
It seems the reason is defining too many environment variables. Where is the maximum size of the environment space defined? Do I have to look into the "busybox" sources, or is this entirely related to the toolchain that I am using?
Any ideas to debug this issue appreciated...
QuoteReplyEditDelete
2010-07-22 10:01:49 Re: application crash when there are many environment variables
Robin Getz (UNITED STATES)
Message: 91587
Timur:
I'm pretty sure this sounds like a stack overlow.
What app is crashing? the shell?
-Robin
QuoteReplyEditDelete
2010-07-22 10:20:14 Re: application crash when there are many environment variables
Timur Aydin (TURKEY)
Message: 91589
Timur:
I'm pretty sure this sounds like a stack overlow.
What app is crashing? the shell?
-Robin
---
The crashes are pretty bizarre. Most of the time the crash happens, sometimes it doesn't. But as I said, I remove half of the env vars, and the application consistently works.
The application is an elf app that I have developed, it's not part of the stock uclinux distribution.
QuoteReplyEditDelete
2010-07-22 10:54:54 Re: application crash when there are many environment variables
Timur Aydin (TURKEY)
Message: 91590
As far as I know, with an ELF application, I don't need to worry about the stack size, At least this is the case on an ELF application running on a MMU CPU. But uclinux on blackfin is NOMMU, so do I have to adjust the stack size as part of the build procedure? I used to do that when my software was FLAT using flthdr, but with ELF, I don't do any adjustment.
QuoteReplyEditDelete
2010-07-22 11:08:08 Re: application crash when there are many environment variables
Robin Getz (UNITED STATES)
Message: 91592
Timur:
>do I have to adjust the stack size as part of the build procedure?
yes.
See: https://docs.blackfin.uclinux.org/doku.php?id=uclinux-dist:debugging_applications#fdpic_elf_binaries
>I used to do that when my software was FLAT using flthdr, but with ELF, I don't do any adjustment.
That's normally because 128k stack is large enough - but there is also fdpichdr.
(But it looks like it needs to be added to the docs - I will do that this afternoon).
-Robin
QuoteReplyEditDelete
2010-07-22 12:35:09 Re: application crash when there are many environment variables
Timur Aydin (TURKEY)
Message: 91599
Robin, thank you for the quick and helpful responses. I am reading the documentation you pointed out.