question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

View constraints which led a state to be unsat

See original GitHub issue

I was trying to find opaque predicates. This is a basic-block which is an opaque predicate:

>>> block.pp()
0x491bc9:       mov     dword ptr [esi + 0x3c], ebx
0x491bcc:       mov     edi, dword ptr [0x590d7c]
0x491bd2:       mov     ebx, dword ptr [0x590d78]
0x491bd8:       mov     eax, edi
0x491bda:       imul    eax, eax
0x491bdd:       imul    eax, eax, 7
0x491be0:       dec     eax
0x491be1:       imul    ebx, ebx
0x491be4:       cmp     eax, ebx
0x491be6:       je      0x491bf5

The cmp eax, ebx instruction just before the conditional jump will always be false since the condition is unsat.

The constraints are: eax * eax * 7 - 1 == ebx * ebx

I am trying to get the constraints using the following snippet:

import angr
import claripy

proj = angr.Project('samples/ac3e087e43be67bdc674747c665b46c2')
block = proj.factory.block(0x00491bc9)

state = proj.factory.blank_state(addr=0x00491bc9)
# state.regs.eax = claripy.BVS('eax', 32)
# state.regs.ebx = claripy.BVS('ebx', 32)

# using save_unsat to store unsat states in unsat stash
# instead of discarding them
simgr = proj.factory.simulation_manager(state, save_unsat=True)

simgr.step()

print(simgr.stashes)

x = simgr.stashes['active'][0]
y = simgr.stashes['unsat'][0]

print(x.solver.constraints)
print(y.solver.constraints)

The problem is, I’m getting the same constraints for both the state in the active stash as well as the one in the unsat stash…

defaultdict(<class 'list'>, {'active': [<SimState @ 0x491be8>], 'stashed': [], 'pruned': [], 'unsat': [<SimState @ 0x491bf5>], 'errored': [], 'deadended': [], 'unconstrained': []})
[<Bool reg_esi_0_32{UNINITIALIZED} + 0x3c <= 0xffffffff>, <Bool reg_esi_0_32{UNINITIALIZED} + 0x3c == 0xffffffff>]
[<Bool reg_esi_0_32{UNINITIALIZED} + 0x3c <= 0xffffffff>, <Bool reg_esi_0_32{UNINITIALIZED} + 0x3c == 0xffffffff>]

My question is, how can I get the constraints which caused the y state to go into the unsat stash?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rhelmotcommented, May 21, 2021

Should be fixed by angr/claripy#220 😄

0reactions
r4dr3fr4dcommented, Nov 12, 2020

Thought I’d check in on this. Every now and then I have a want to see what’s specifically unsatisfiable and every time unsat_core() returns an empty list for me as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto Layout Guide: Anatomy of a Constraint - Apple Developer
The first layout constrains the view's leading edge relative to its superview's leading edge. It also gives the view a fixed width.
Read more >
Unsatisfiable Constraint for NSLayoutConstraint changed ...
Which basically states that the constraints I have don't work well togheter. I don't know what I'm doing wrong. EDIT: This is the...
Read more >
Theory of Constraints (TOC) - Lean Production
Dr. Eliyahu Goldratt conceived the Theory of Constraints (TOC), ... Diagram that shows the current state, which is unsatisfactory and needs improvement.
Read more >
Debugging Overconstrained Declarative ... - Manu Sridharan
addressing the problem of overconstraints in declarative models. ... Then we see the blunder: the fact states that all servers.
Read more >
Finding Minimal Unsatisfiable Cores of Declarative ...
constraints ; and NCE and SCE, which are sound and minimal, but run much ... Each of these cases leads to an identifiable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found