-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shell fails on SBRK out of heap (address wrap) on script #2180
Conversation
When I simply put an OUT OF HEAP still triggers. So I assume it has something to do with the filesize rather than its commands/code? Edit: Yea, maybe. Before it was 3070 bytes and now it's 4229 bytes. Crosses a magic 4096 (page?) size? |
Try increasing /bin/sh's heap size in elkscmd/ash/Makefile. It's set to 12k to try to keep the resident working set small since at least one shell is almost always running. This can be fine-tuned later if this is found to be the issue. The shell data segment is also alway duplicated entirely on 'fork' so keeping it small helps run programs when memory is extremely tight. Regarding the changes to the script, I would recommend adding a -p option to mknod instead of using 'test' with all the duplicated script code.
The 8086 has no notion of page size, since there is no MMU. However, /bin/sh itself could be requiring more heap with an increased script size, I am not familiar with the internals of shell script processing but can figure that out if this continues to be a problem. The bin/sys script itself had been previously meticulously crafted down to below 3K bytes to keep the distribution image size smaller, since it is on every disk image. Of course, it will have to cross 3K with this enhancement, but can easily be made less than 4k bytes with the mknod -p change. |
Thanks for the input. I'll explore the In my feature branch I still find This makes me believe that I have not a synced source tree. When I switch to my master the file is away! My git tree was made synced with yours before I started creating the feature branch today. And If not, I think your comment sounds "it's kind of expected" and I will check the options your wrote. |
I'm definitely not a git wizard, and don't normally like renaming files as I believe it might affect the searchability for file history. If you think you're tree is screwed up, sometimes I will clone a new tree from start then move the cross/ directory over from the old tree so as to not have to recompile the GCC toolchain. |
Neither of the alloc changes should affect any of this since /bin/sh doesn't use v7malloc (now named dmalloc.c). I do believe it strange that your tree still has v7malloc.c, as that was renamed as you stated. |
Hello @floriangit,
Have you determined whether this issue resulted from a repo sync issue, or is there a heap space problem with /bin/sh that needs to be looked into? If the former, please close this issue, otherwise I'll leave this open and lets work to get this duplicated on my side so I can trace down the issue. Thank you! |
0bd346d
to
2e20e1f
Compare
Hi @ghaerr, FWIW, I deleted as suggested my local repo and cloned again. I then tried things again with my "noisy/big sys". I was still running out of heap, then 1 doubled the heap size in ash/Makefile, still same. I then quadrupled to 48k heap and still the same. I stopped at that point. 48k sounds a lot, though, so maybe there is another reason? I will raise it again when it should happen. |
It sounds to me that there is a problem with /bin/sh and an address wrap on the sbrk system call, for some reason. Do you still have the offending shell script? The "SBRK OUT OF HEAP (address wrap)" message indicates that the amount being requested to increase/decrease the heap overflows the 16-bit add/subtract and wraps - which is a bit different than just requesting a smaller amount of heap that isn't available. It may be the shell is doing this for some reason with your offending script. If I can duplicate with your original script, I can reopen this issue and debug it. |
https://github.com/floriangit/elks/tree/heap_hunters This fails for me when executing Do you need a PR? |
No - I pulled your |
Thanks for checking all this. The error is the same as yours indeed. So I might have mixed that small semantics up. Of course I did not know to manually delete the ash binary before building (needs build system fix, no?), so I did not do that, which explains I could not fix the error by changing the heap on my end. Noted the 'rm -f' hint for
Also this is thankfully no problem. I just added the |
@floriangit, I think I've finally figured all this out. As you have seen, #2186 fixes the It appears you ran into problems because elkscmd/ash/ash was not being rebuilt when elkscmd/ash/Makefile was modified. Is this a build system bug? I don't know - in order to fix this, every single Makefile would have to add "Makefile" as a dependency for every single target. I would think that So for now, we don't need to change anything. I've made a note to look further into this at a later time; I haven't learned yet whether the heap overflow is on execution of the |
Thanks, I see you brought it all together now and saved me some work!
I mentioned earlier, that I placed an
I never thought about this to be honest. I implicitly expected I'll test your |
Note, that with this change I'm running into the SBRK FAIL, OUT OF HEAP (address wrap) message you added in:
#2134
As I'm puzzled why my changes would trigger that, I've created this PR.