libmem icon indicating copy to clipboard operation
libmem copied to clipboard

Fix FreeBSD memory problems (???)

Open rdbo opened this issue 2 years ago • 2 comments

The tests on FreeBSD are failing during the hooking of some_function in test1.c. The reason for that is not clear yet.

rdbo avatar Dec 24 '22 17:12 rdbo

It seems to be allocating the trampoline memory as write only:

[*] Some Function Trampoline: 0x801038000

proc maps:
         0x801038000        0x801039000     0x1000    0x20000  -w- ---- 

This doesn't make sense, because it is being allocated with PROT_EXEC | PROT_READ | PROT_WRITE, which is what LM_PROT_XRW is set as.

rdbo avatar Jan 04 '23 01:01 rdbo

I just recompiled libmem on FreeBSD with the warning fixes and things got even wilder. It is crashing on LM_CALLOC, even though both parameters are valid:

LM_CALLOC(len + 1, sizeof(lm_byte_t));

And it is also crashing on mmap:

mmap(NULL, size, prot, MAP_PRIVATE | MAP_ANON, -1, 0)

Error:

Program received signal SIGSEGV, Segmentation fault.
Invalid permissions for mapped object.

Again, no clue what this is.

rdbo avatar Jan 04 '23 13:01 rdbo