-
Notifications
You must be signed in to change notification settings - Fork 42
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
depmod: Actually use scratch buffer memory #166
Conversation
76529e0
to
657a240
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
On a related note since you are reviewing these things. I was thinking of blending strbuf and scratchbuf, always allowing to start with a stack buffer and if NULL is passed, then the current behavior for strbuf is retained. Any thoughts?
I've had an idea like that as well, also possibly backing array creations with scratchbuf. The concept of scratchbuf is awesome, since a lot of allocations could be skipped when it comes to heuristics and common module setups in distributions. But I didn't make any progress into that direction, so: Yes I would like to see that, but have no code to share. :D |
Accessing the backing "alias" char buffer directly works only as long as all symbols are smaller than 1024, because otherwise the scratch buffer allocates memory and the addresses do not match anymore. Signed-off-by: Tobias Stoeckmann <[email protected]>
It is meant as a backing buffer for scratch buffer. Do not use it directly when constructing strings. Co-authored-by: Lucas De Marchi <[email protected]> Signed-off-by: Tobias Stoeckmann <[email protected]>
f962d2d
to
f1f010d
Compare
I started doing that and left saved on a branch... I will try to finish it and submit as a PR |
Accessing the backing "alias" char buffer directly works only as long as all symbols are smaller than 1024, because otherwise the scratch buffer allocates memory and the addresses do not match anymore. Signed-off-by: Tobias Stoeckmann <[email protected]> Link: #166 Signed-off-by: Lucas De Marchi <[email protected]>
It is meant as a backing buffer for scratch buffer. Do not use it directly when constructing strings. Co-authored-by: Lucas De Marchi <[email protected]> Signed-off-by: Tobias Stoeckmann <[email protected]> Link: #166 Signed-off-by: Lucas De Marchi <[email protected]>
Applied, thanks. |
Accessing the backing "alias" char buffer directly works only as long as all symbols are smaller than 1024, because otherwise the scratch buffer allocates memory and the addresses do not match anymore.
Proof of Concept:
aa
and1025*A
(i.e. longer than 1024 characters)You can see, among other warnings, this one:
Since the
1025*A
symbol name triggered an allocation within the scratch buffer, the first symbol nameaa
has been added twice. The1025*A
symbol name can be seen in writtenmodules.symbols
file, but not inmodules.symbols.bin
(because the scratch buffer issue is triggered in second output).