Skip to content

Symex: havocking a string literal has no effect - #9496

Open
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:fix/symex-havoc-string-literal
Open

tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:fix/symex-havoc-string-literal

Conversation

@tautschnig

@tautschnig tautschnig commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

__CPROVER_havoc_object(p) with p pointing to a string literal failed the invariant "Attempted to symex havoc applied to unsupported expression", as dereferencing p yields the string constant itself. String literals (and other constants) are not objects whose value can change, so there is nothing to havoc.

Update after a review of the whole inline-assembly stack

havoc_rec now recognises read-only objects with goto_symex_statet::is_read_only_object, as symex_assign does. The previous check only matched ID_string_constant and constants, which misses wide and Unicode string literals and the part of a literal that a pointer into its middle refers to: these are arrays. The test now covers both cases. It runs with --no-pointer-check because of two problems on develop that are independent of this PR: reading a wide string literal gives a spurious pointer-check failure, and the SMT2 back end fails an invariant in convert_address_of_rec.

  • 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.

Copilot AI balanced review requested due to automatic review settings November 16, 2026 07:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.34%. Comparing base (3e1f386) to head (931a93b).
⚠️ Report is 36 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #9496      +/-   ##
===========================================
+ Coverage    81.29%   81.34%   +0.04%     
===========================================
  Files         1725     1727       +2     
  Lines       191680   191716      +36     
  Branches        73       73              
===========================================
+ Hits        155835   155949     +114     
+ Misses       35845    35767      -78     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

__CPROVER_havoc_object(p) with p pointing to a string literal failed the
invariant "Attempted to symex havoc applied to unsupported expression", as
dereferencing p yields the literal itself: a string constant for a narrow
string literal, and an array for a wide or Unicode string literal or for
the part of any literal that a pointer into its middle refers to.

String literals and other constants are not objects whose value can
change, so there is nothing to havoc. Use
goto_symex_statet::is_read_only_object, which symex_assign uses to ignore
writes to such objects, to recognise them.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@tautschnig
tautschnig force-pushed the fix/symex-havoc-string-literal branch from 4e8cd96 to 931a93b Compare December 2, 2026 06:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants