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

AssignmentExpression assert nullptr Error #19

Closed
saeschdivara opened this issue Feb 12, 2015 · 8 comments
Closed

AssignmentExpression assert nullptr Error #19

saeschdivara opened this issue Feb 12, 2015 · 8 comments
Labels

Comments

@saeschdivara
Copy link

Assertion failed: (spSrcExpr != nullptr && "Source expression is null"), function AssignmentExpression, file /src/core/expression.cpp, line 342.

The file is a pe x86 Intel Windows Executable.

This happens, qMedusa stops to work and nothing of the progression was saved.
Is there something not fully implemented that this can happen? Or how can I fix this?

I am working with the newest code of the master branch.

@saeschdivara
Copy link
Author

I am preventing the abortion with this code:

    Expression::SPType operand0 = rInsn.GetOperand(0);
          Expression::SPType operand1 = rInsn.GetOperand(1);

          if (operand1 == nullptr) {
              Log::Write("operand 1 is null");
              return false;
          }

          auto pExpr1 = /* Semantic: if zf.id == int1(1): op0.val = op1.val */
          Expr::MakeIfElseCond(
            ConditionExpression::CondEq,
            Expr::MakeId(X86_FlZf, &m_CpuInfo),
            Expr::MakeConst(1, 0x1),
            Expr::MakeAssign(operand0, operand1),
            nullptr);
          AllExpr.push_back(pExpr1);
          rInsn.SetSemantic(AllExpr);

in the following file: src/arch/x86/x86_opcode.cpp

@wisk
Copy link
Owner

wisk commented Feb 13, 2015

It may looks radical, but this behavior is desired. Just attach a debugger and look in the call stack to find the buggy instruction.
I can take a look on this bug if you can share your executable. :)

@wisk wisk added the bug label Feb 13, 2015
@saeschdivara
Copy link
Author

Well, how could I best share this exe with you?

@wisk
Copy link
Owner

wisk commented Feb 13, 2015

4shared.com is ok I guess.

@saeschdivara
Copy link
Author

I really think that the code of the file has something wrong. At least if I look at this: http://pedump.me/a772ef7449783ee4edc60dd0b006ffe6/#disasm

@wisk
Copy link
Owner

wisk commented Feb 14, 2015

Thanks for sharing, the buggy instruction was cmpxchg8b, the fix is 1d61c8e

@wisk wisk closed this as completed Feb 14, 2015
@saeschdivara
Copy link
Author

Hey I've just tested your fix. It works :)
Nice job.
How do you test these things? Just debugging the application or using something different?

@wisk
Copy link
Owner

wisk commented Feb 14, 2015

Thanks, it's actually pretty easy to debug these issues:

  • start qMedusa with a debugger,
  • wait for the assert to make the application crash,
  • the debugger catches this exception/signal and stops,
  • display the callstack
  • find the faulty instruction
  • ???
  • profit :)

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

2 participants