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

Unary negation (~) operator appears to be broken in the assembler expression calculator #2659

Open
sam-xif opened this issue Jul 10, 2024 · 0 comments
Labels

Comments

@sam-xif
Copy link

sam-xif commented Jul 10, 2024

Summary of the problem

Hello manticore community,

I am working as part of a research team developing a code analysis tool for Python. One of the issues the tool discovered in manticore's codebase is that the unary negation (~) operator appears to be broken. Whenever even a simple expression, such as ~0x30, is entered, the parser exits with an unhandled error. See below for stack trace.

If you are interested in learning more about the tool and how it found this issue, let me know down in the comments, or you can contact me at xifaras.s@northeastern.edu. We are primarily curious about whether you find that this issue is legitimate and worth reporting and fixing. If not, we would be interested in understanding why.

Thank you for your consideration!

-Sam

Manticore version

Latest master (commit hash: 8861005)

Python version

Python 3.8

OS / Environment

Linux (kernel version 5.10.218)

Dependencies

N/A

Step to reproduce the behavior

Enter an expression that uses the unary negation operator, such as ~0x30 or ~3 & 4.

Expected behavior

The unary negation operator works as expected

Actual behavior

Traceback example:

sxifaras@login-4:/data1/groups/neu-type-fuzzing/data/repos/manticore$ python -m manticore.core.parser.parser
calc > 3 & 4
0
calc > ~3 & 4
Traceback (most recent call last):
  File "/state/partition1/llgrid/pkg/anaconda/anaconda3-2021b/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/state/partition1/llgrid/pkg/anaconda/anaconda3-2021b/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/data1/groups/neu-type-fuzzing/data/repos/manticore/manticore/core/parser/parser.py", line 355, in <module>
    result = parse(s)
  File "/data1/groups/neu-type-fuzzing/data/repos/manticore/manticore/core/parser/parser.py", line 339, in parse
    result = parser.parse(expression, tracking=True)
  File "/data1/groups/neu-type-fuzzing/data/packages/manticore/ply/yacc.py", line 331, in parse
    return self.parseopt(input, lexer, debug, tracking, tokenfunc)
  File "/data1/groups/neu-type-fuzzing/data/packages/manticore/ply/yacc.py", line 823, in parseopt
    p.callable(pslice)
  File "/data1/groups/neu-type-fuzzing/data/repos/manticore/manticore/core/parser/parser.py", line 206, in p_expression_neg
    p[0] = ~p[1]
TypeError: bad operand type for unary ~: 'str'
@sam-xif sam-xif added the bug label Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant