Skip to content
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

Precise strdup #1141

Open
5 tasks
sim642 opened this issue Aug 21, 2023 · 6 comments
Open
5 tasks

Precise strdup #1141

sim642 opened this issue Aug 21, 2023 · 6 comments

Comments

@sim642
Copy link
Member

sim642 commented Aug 21, 2023

Currently strdup (and strndup) return an unknown pointer, which can make things very imprecise. Instead we should:

  • Return a pointer to freshly allocated memory, the same way as malloc.
  • Create a corresponding blob as its value.
  • Blob size should come from the argument string constant or blob size.
  • Blob contents should copy the argument blob contents or summarize the string constant.
  • strndup should additionally only have maximum length n and copy as long prefix.
@michael-schwarz
Copy link
Member

@nathanschmidt will tackle this as it is quite related to his string domain work.

@sim642
Copy link
Member Author

sim642 commented Sep 14, 2023

Now that the thesis is done, will this still be worked on or not?
I don't recall where I originally noticed this, but this may be quite crucial now because silver searcher has lots of likely-spurious race warnings related to a strndup. I don't know for sure whether this would avoid them, but we might have to do this ourselves since the PLDI paper is high priority.

@nathanschmidt
Copy link
Collaborator

Now that the thesis is done, will this still be worked on or not?

Sorry I haven't found the time to do so yet. I'll try to do this next week, let me know if that is soon enough

@michael-schwarz
Copy link
Member

If you can get around to it next week, I think that is timely enough; However, please don't feel obligated to do it if you don't want to, as the thesis is officially over now.

@sim642
Copy link
Member Author

sim642 commented Sep 18, 2023

After some more digging into silver searcher it appears that strdup might not be the main biggest hurdle. Rather it seems proper value analysis of thread-local variables (#876) is more crucial to get rid of unknown pointers that cause imprecise type-based memory accesses.

@michael-schwarz
Copy link
Member

Nathan has finished his thesis now and will sadly not have time to work on this, so I unassigned him.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants