You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
hackmud fails to launch sometimes, failed assertion in Mono #131
I get the same message as in #105, except I don't get any error messages about opcodes.
TYPE: 31
* Assertion at mini-amd64.c:209, condition 'amd64_is_imm32 (disp)' not met
Stacktrace:
* Assertion: should not be reached at interp-stubs.c:105
I need to understand were this pointer came from. I assume it comes from a mmap or malloc or something similar, but I haven't found the source yet.
But maybe it comes from something else, some api call or something like that?
This means that we attempt to call fmod, which is located at 0xa149e4e0, from our JIT'd code, which is located at 0x130acc. If we do a quick subtraction, we see that 0xa149e4e0 - 0x130acc = 0xa136da14, which is out of signed 32-bit range, and therefore fails amd64_is_imm32:
If we take a look at the memory mapping of the process, this is how it looks:
0012f000-00135000 rwxp 00000000 00:00 0 # this is where Mono puts the JIT'd code
00400000-00401000 r-xp 00000000 b3:02 535223 hackmud # this is where the main executable is mounted
a1269000-a1549000 rw-p 00000000 00:00 0 [heap] # this is where wrapped libm is mounted
A possible fix would be to make sure that box64 maps memory and mounts libraries before 0x7fffffff.
Also, "signed i32". Damn, that's half what I was counting on.
Easy solution would be to make the bridges nearer. I currently use posix_memalign(...) to get the bridges address (were the fmod will get is address on box64). I guess I will have to use a memmap(...) instead, and ask for a low 32bits address.
It's not librarian here. It's the bridges, because libm is a wrapped one.
Note that I will not be able to tests box64 in the next few days. But I should still be able to look at PR (and there is CI with travis now on box64 too)
Look in tools/bridge.c the function NewBrick(...) does the allocation. Use my_mmap(...) if you want to use MAP_32BIT, as it doesn't exist in Aarch64. Or look at my_mmap(...) to see how that flags is emulated (using some functions in custommem.c)
Activity
ptitSeb commentedon Oct 11, 2021
Yes, I still don't know why some pointer are not 32bits.
mogery commentedon Oct 11, 2021
@ptitSeb If I can do anything to help you figure this out, let me know.
ptitSeb commentedon Oct 11, 2021
I need to understand were this pointer came from. I assume it comes from a mmap or malloc or something similar, but I haven't found the source yet.
But maybe it comes from something else, some api call or something like that?
mogery commentedon Oct 11, 2021
For some reason I'm having trouble getting this to trigger from within GDB.
mogery commentedon Oct 11, 2021
Ok, yeah, after like an hour of running gdb over and over and over again, this does not happen in GDB.
It still can happen if I attach GDB afterwards, but
backtracefails:mogery commentedon Oct 12, 2021
Oh my, after hours of digging through mono source code, adding debug messages, and recompiling, I finally figured it why it crashes.
So, the issue happens when mono's JIT tries to emulate a call to its IL's FREM opcode.
It emulates this opcode with a pointer to
fmod.So, when we run the code, we crash at a JIT'd call to __emul_frem (= fmod).
Let's see some debug logs I've printed out:
This means that we attempt to call fmod, which is located at
0xa149e4e0, from our JIT'd code, which is located at0x130acc. If we do a quick subtraction, we see that0xa149e4e0 - 0x130acc = 0xa136da14, which is out of signed 32-bit range, and therefore failsamd64_is_imm32:If we take a look at the memory mapping of the process, this is how it looks:
A possible fix would be to make sure that box64 maps memory and mounts libraries before
0x7fffffff.ptitSeb commentedon Oct 12, 2021
Oh, wow, well done!
Do you know if there is other function called, other than
fmodandfmodf?ptitSeb commentedon Oct 12, 2021
Also, "signed i32". Damn, that's half what I was counting on.
Easy solution would be to make the bridges nearer. I currently use
posix_memalign(...)to get the bridges address (were thefmodwill get is address on box64). I guess I will have to use amemmap(...)instead, and ask for a low 32bits address.mogery commentedon Oct 12, 2021
I have no idea, but it might be good practice to use
mmapin librarian with the MAP_32BIT flag for all libraries.I'll test and open a PR.
ptitSeb commentedon Oct 12, 2021
It's not librarian here. It's the bridges, because
libmis a wrapped one.Note that I will not be able to tests box64 in the next few days. But I should still be able to look at PR (and there is CI with travis now on box64 too)
mogery commentedon Oct 12, 2021
Oh alright, thanks for letting me know. I'll play around with the code.
ptitSeb commentedon Oct 12, 2021
Look in
tools/bridge.cthe functionNewBrick(...)does the allocation. Usemy_mmap(...)if you want to useMAP_32BIT, as it doesn't exist in Aarch64. Or look atmy_mmap(...)to see how that flags is emulated (using some functions incustommem.c)Map bricks below first 2GB of address space