Skip to content

Concurrency: treat updates to an unknown field as atomic #6123

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

Merged
merged 1 commit into from
May 12, 2023

Conversation

tautschnig
Copy link
Collaborator

Writing to an object that is composed of multiple fields is generally
treated in a field-sensitive (and thus: single-field) manner, which had
fixed several issues in handling shared arrays or structs. When the
specific field being updated cannot be determined during symbolic
execution (as is the case with non-const indices into arrays), we update
all fields that make up the full object. Such a full-object update must
then be treated as an atomic operation to avoid losing intermittent
writes performed by other threads.

Fixes: #123

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@codecov
Copy link

codecov bot commented May 14, 2021

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.09 🎉

Comparison is base (535e6b2) 78.38% compared to head (f5b35b4) 78.48%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6123      +/-   ##
===========================================
+ Coverage    78.38%   78.48%   +0.09%     
===========================================
  Files         1686     1686              
  Lines       192915   192926      +11     
===========================================
+ Hits        151215   151412     +197     
+ Misses       41700    41514     -186     
Impacted Files Coverage Δ
src/goto-symex/goto_symex.cpp 98.67% <100.00%> (+0.02%) ⬆️

... and 20 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

// We may end up reading (and writing) all components of an object composed
// of multiple fields. In such cases, we must do so atomically to avoid
// overwriting components modified by another thread. Note that this also
// implies multiple shared reads on the rhs being treated as atomic.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment that makes this clear but ... I am a little concerned about this because now
struct s = t; and

struct s;
s.x = t.x;
s.y = t.y;

can have different behaviour. I guess there is a very valid question about what the atomic actions in the CPROVER concurrency model are.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this case shouldn't arise for structs and mainly affects arrays: you are absolutely right that this is questionable either way. Without this patch, we'll have spurious results (as documented in the regression test). With this patch, we may miss some behaviour, depending on what exactly we otherwise consider to be atomic.

@tautschnig tautschnig force-pushed the concurrency-field-updates branch from 7177fc4 to aee96fc Compare February 26, 2022 18:15
@tautschnig tautschnig force-pushed the concurrency-field-updates branch from aee96fc to a0485f2 Compare October 27, 2022 09:27
@tautschnig tautschnig force-pushed the concurrency-field-updates branch 2 times, most recently from a6b0363 to 0d6eb2e Compare November 22, 2022 10:41
@tautschnig tautschnig force-pushed the concurrency-field-updates branch from 0d6eb2e to fe8b401 Compare February 23, 2023 10:00
@peterschrammel peterschrammel removed their assignment May 10, 2023
Writing to an object that is composed of multiple fields is generally
treated in a field-sensitive (and thus: single-field) manner, which had
fixed several issues in handling shared arrays or structs. When the
specific field being updated cannot be determined during symbolic
execution (as is the case with non-const indices into arrays), we update
all fields that make up the full object. Such a full-object update must
then be treated as an atomic operation to avoid losing intermittent
writes performed by other threads.

Fixes: diffblue#123
@tautschnig tautschnig force-pushed the concurrency-field-updates branch from fe8b401 to f5b35b4 Compare May 12, 2023 13:57
@tautschnig tautschnig assigned tautschnig and unassigned kroening May 12, 2023
@tautschnig tautschnig merged commit 221022f into diffblue:develop May 12, 2023
@tautschnig tautschnig deleted the concurrency-field-updates branch May 12, 2023 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug in concurrency encoding for arrays and structs
5 participants