Assertion failure

28 views
Skip to first unread message

zhaper

unread,
May 17, 2013, 12:03:13 AM5/17/13
to asmji...@googlegroups.com
Hi,

I'm getting the following assertion failure:

*** ASSERTION FAILURE at c:\x86obf\x86obf\asmjit\core\../core/buffer.h (line 145
)
*** getOffset() + 1 <= _capacity

what can I do to fix this?

zhaper

unread,
May 17, 2013, 12:08:25 AM5/17/13
to asmji...@googlegroups.com
Forgot to mention: It happens on A.call(label) (the first instruction emitted, however prior to doing that, I create a bunch of labels -- if that matters).

Petr Kobalíček

unread,
May 17, 2013, 6:35:28 AM5/17/13
to asmjit-dev
Hi Zhapper,

I will check this out today, seems like easy bug to find.

Thanks!
 
Best,
Petr

--
 
---
You received this message because you are subscribed to the Google Groups "asmjit-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to asmjit-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

zhaper

unread,
May 19, 2013, 11:20:23 AM5/19/13
to asmji...@googlegroups.com
Hey,

any news?

Petr Kobalíček

unread,
May 19, 2013, 12:24:50 PM5/19/13
to asmjit-dev
Hi,

I just tried very simple sample, but it works for me:

  X86Assembler a;

  Label label = a.newLabel();
  for (size_t i = 0; i < 10000; i++)
    a.newLabel();

  a.call(label);
  void* p = a.make();

Do you have a snippet that will fail?

And, which version are you using, svn or downloaded beta?

Best,
Petr


On Sun, May 19, 2013 at 6:20 PM, zhaper <zha...@gmail.com> wrote:
Hey,

any news?

zhaper

unread,
May 19, 2013, 3:19:59 PM5/19/13
to asmji...@googlegroups.com
I used beta, but upgraded to SVN and it's still the same. Unfortunately, I don't have an example right now, I'll try to create one and let you know.

Petr Kobalíček

unread,
May 19, 2013, 3:25:48 PM5/19/13
to asmjit-dev
Hi,

if you send me a call-stack and content of Buffer members I can try to look if there is something suspicious. I'm preparing an update, but unfortunately it's still not ready.

Best regards
Petr Kobalicek

zhaper

unread,
May 19, 2013, 4:13:02 PM5/19/13
to asmji...@googlegroups.com
It does not crash at A.call() anymore (however, I have not changed anything).

I had this function:

DWORD obf_write_memory(X86Assembler *A, UINT8 *data, DWORD len)
{
DWORD off;

if (!len) {
obf_error("Writing memory of zero bytes");
}

off = A->getCodeSize();

for (unsigned i = 0; i < len; i++) {
A->_emitByte(data[i]);
}

return off;
}

it crashed on _emitByte (but not the first call), I replaced it with A->data() and it works fine. I remember having this issue before, however I simply used A.nop() instead of emitByte because it was for uninitialized data.

Petr Kobalíček

unread,
May 19, 2013, 4:43:50 PM5/19/13
to asmjit-dev
Oh I see!

Now it's clear. The _emitByte() never grows the internal buffer. When Assembler emits an instruction it calls 'ensureSpace' to ensure that there is enough free space to fit any instruction.

Using a->data() is safe, because it can grow the buffer.

I'm glad it's solved ;)

Best,
Petr
Reply all
Reply to author
Forward
0 new messages