Opened on 01/15/16 at 08:27:14
Last modified on 02/15/17 at 13:37:51
#2528 assigned defect
Update https://devel.rtems.org/wiki/TBR/Delete/NewlibMemoryAllocation
Reported by: | Nick Withers | Owned by: | Needs Funding |
---|---|---|---|
Priority: | normal | Milestone: | Indefinite |
Component: | tool/newlib | Version: | 4.11 |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: |
Description
This'll require a re-audit of Newlib code.
Ideally, it would also detail where dynamic memory allocation is used in RTEMS code, too, and give an indication of whether it's initialisation-time only
Change History (18)
comment:1 Changed on 01/15/16 at 08:28:11 by Nick Withers
Owner: | set to Nick Withers |
---|---|
Status: | new → accepted |
comment:2 Changed on 01/15/16 at 15:55:52 by Gedare Bloom
You could put together GCI tasks to audit the existing ones at least. You should consider relocating the wiki page to somewhere else. I'm not sure where.
comment:3 Changed on 01/17/16 at 01:25:54 by Nick Withers
How does https://codein.withgoogle.com/dashboard/tasks/5374361066274816/preview/ look?
It only attempts to have students find occurrences, not actually audit them (e.g., can they be avoided), which might be too hard and too much work (to do them all, anyway)
comment:4 Changed on 01/17/16 at 15:37:13 by Gedare Bloom
Do you expect one student to complete the entire task? Or should the task be subdivided?
Add "Research/Outreach" task type too.
You might want to fill in one row of each table as an example, and give a little more instruction about what should go into each column that the student is expected to fill in.
comment:5 Changed on 01/18/16 at 07:37:27 by Nick Withers
Righto, cheers.
Do you expect one student to complete the entire task? Or should the task be subdivided?
Yeah, I think it should be subdivided, especially as I've now added e.g., posix_memalign() to the list. Would you mind if I do that after we're happy with everything else, though?
Also, should it only be for newlib/libc/ and below (e.g., excluding libgloss)?
comment:6 Changed on 01/18/16 at 12:52:30 by Gedare Bloom
Exclude libgloss. AFAIK we don't use anything from it...
comment:7 Changed on 01/19/16 at 01:09:52 by Nick Withers
Righto, updated to specifically limit it to the newlib/libc directory.
I'm now thinking it might be better not to split it, as there's likely to be a disproportionate workload for e.g., each of the three tables...?
comment:8 Changed on 01/19/16 at 02:01:31 by Gedare Bloom
Yeah just post 1 task and see if anyone takes it. There's only 1 week or so left in the contest anyway.
comment:9 Changed on 01/19/16 at 02:05:29 by Nick Withers
If you're happy with it, feel free to publish; I don't think I can
comment:10 Changed on 01/25/16 at 05:52:32 by Nick Withers
Time has now passed for GCI students to pick up new tasks and unfortunately this one hasn't been selected.
I'll get onto it this week or next
comment:11 Changed on 02/02/16 at 02:20:20 by Nick Withers
I think I've underestimated the work involved in producing a useful breakdown in a maintainable and error-free way, here.
Whilst I could just produce a list of files, line numbers and functions directly calling e.g., malloc(), I don't think that's very useful... What I'd like to know, as an application developer, is what functions I might call from my application that might result in memory allocation attempts. A simple grep's going to turn up lots of implementation detail (e.g., file-static functions that call malloc(), whereas I'd want instead the functions that are exposed to RTEMS applications that might call it).
Add in function pointers (e.g., ucs_2_init() in iconv/ces/ucs-2.c is pointed to by _iconv_to_ucs_ces_handlers_ucs_2.init, the latter struct then gets indexed by string in iconv_to_ucs_ces_t _iconv_to_ucs_ces), and a bunch 'o #defines and... my brain hurts.
Can anyone suggest tools which might help here? Otherwise we should perhaps just delete the article...
comment:12 Changed on 02/02/16 at 04:11:18 by Joel Sherrill
http://www.gnu.org/software/cflow/ or a similar tool might be helpful.
But this also might be a good discussion to move to newlib's mailing list. What we really want is to know which public API calls can result in memory allocation.
comment:13 Changed on 02/02/16 at 04:31:11 by Nick Withers
I don't think cflow (or cscope) can handle e.g., calls through function pointers.
But this also might be a good discussion to move to newlib's mailing list. What we really want is to know which public API calls can result in memory allocation
Agreed, and well put. Ideally they'd maintain that information and insist it were updated when commits change the situation
comment:14 Changed on 02/03/16 at 12:52:45 by Gedare Bloom
Dealing with function pointers is hard. I did something before http://gedare-csphd.blogspot.com/2013/05/whos-calling-me-visualizing-function.html but again it did not follow dynamic code flow. For that you need something that can process a trace. There may also be some tools in the clang/llvm project that can generate similar.
comment:15 Changed on 02/04/16 at 07:17:53 by Sebastian Huber
One approach would be to use the linker to resolve the dependencies. For example build a BSP with --enable-tests and use a test without references to malloc() etc.
sparc-rtems4.12-gcc -B../../../../../sis/lib/ -specs bsp_specs -qrtems -mcpu=cypress -O2 -g -ffunction-sections -fdata-sections -Wall -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs -Wl,-Map,map.txt -Wl,--gc-sections -mcpu=cypress -o spinternalerror01.exe init.o -Wl,-u,strftime
nm *.exe | grep '\<malloc\>\|\<calloc\>\|\<realloc\>'
0200b394 T malloc
0200b774 T realloc
comment:16 Changed on 02/11/16 at 01:54:41 by Nick Withers
Owner: | Nick Withers deleted |
---|---|
Status: | accepted → new |
Thanks for your Newlib mailing list post, Joel (https://sourceware.org/ml/newlib/2016/msg00052.html)!
It doesn't seem to have attracted any attention yet, unfortunately.
comment:17 Changed on 01/26/17 at 07:16:00 by Sebastian Huber
Milestone: | 4.11.1 → 4.11.2 |
---|
comment:18 Changed on 02/15/17 at 13:37:51 by Sebastian Huber
Milestone: | 4.11.2 → Indefinite |
---|---|
Owner: | set to Needs Funding |
Status: | new → assigned |
I plan to do this next week, as it may be too much for a GCI task