-
Notifications
You must be signed in to change notification settings - Fork 447
Fix statically allocated objects #1688
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
base: master
Are you sure you want to change the base?
Fix statically allocated objects #1688
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1688 +/- ##
==========================================
+ Coverage 63.58% 63.60% +0.01%
==========================================
Files 244 244
Lines 25741 25730 -11
Branches 4510 4508 -2
==========================================
- Hits 16368 16365 -3
+ Misses 9373 9365 -8
🚀 New features to boost your workflow:
|
@adriaanjacobs I finally had some time to review this pull request. I don't think we have to change this line here, as Please let me know your thoughts and update the patch accordingly. Thanks. |
Thanks for taking a look. I don't think I fully understand what the void* func() {
char data[SIZE];
return &data[0];
} I've confirmed that all changed ExtAPI functions were previously (before #1616) |
Some c standard library API like I had another look at
Let me know your thoughts. |
The original design didn't distinguish between external functions allocating static objects or stack objects—it essentially treated them all as stack objects. So, simply reverting #1616 isn't enough, which is also why you didn't encounter build failures in #1688, as static object allocation for external functions wasn't addressed. |
@adriaanjacobs could you check the above the update the pull request and let me know if any questions |
If i understand correctly, you proposal is to create a new node for each call to a "static return" function? We think there are two requirements SVF should fulfil to correctly handle these functions. We don't think creating a new node for each call site is the correct approach as it satisfies the second requirement but not the first. All the nodes would still be seen as different nodes and thus not alias, if I'm not mistaken. |
|
Very good points! We may need two types annotations for distinguish whether a extAPI returns a shared or an individually created object node. SHARED_STATIC_OBJECT or INDIVIDUAL_STATIC_OBJECT To satisfy your Requirement 1: SHARED_STATIC_OBJECT should be used for each ext function (one llvm function value to one shared static/global object). To satisfy your Requirement 2: for mapping a node back to llvm value, I think we need each SHARED_STATIC_OBJECT to be an individually defined global variable in the extapi.c. Let me know your thoughts. I am unsure which test case you mentioned failed. But Requirement 1 does introduce conservative and spurious results. |
In #1693, we removed the "ALLOC_STACK_RET" annotation for APIs that return statically allocated objects. Instead, we now handle these cases by introducing a global variable for each such API, which allows us to model shared static objects. We also retain the "ALLOC_STACK_RET" annotation for APIs that are expected to return a newly allocated object on each call. @mortkever and @adriaanjacobs, does this work for you? or any other thoughts or ideas? |
Hi
As discussed in #1680, this patch largely reverts #1616, which mistakenly seems to refer to statically-allocated objects as "stack-allocated objects". As far as we can tell, this lead to only 1 bug in SVF, in the SVFIRBuilder, where a regular
isa<Alloca>
was replaced with a function to check for a call to an extapi func returning "stack-allocated storage" (which actually returned an unknown static object). That's obviously wrong. Fixed in 4d7ece4e5b4.However, we (surprisingly!) did not notice any build failures after updating this naming convention and deleting some utility functions. Does that mean that SVF does not check for statically-allocated objects in its handling of external calls? I'm confused here: where should we find & update t 8000 he code that treats all calls to such functions as aliasing?
I believe there's more work to be done to properly handle these STATIC_RET functions. @mortkever/@shuangxiangkan any ideas?