summary refs log tree commit diff stats
path: root/results/scraper/box64/2598
diff options
context:
space:
mode:
Diffstat (limited to 'results/scraper/box64/2598')
-rw-r--r--results/scraper/box64/259833
1 files changed, 33 insertions, 0 deletions
diff --git a/results/scraper/box64/2598 b/results/scraper/box64/2598
new file mode 100644
index 000000000..7fb75dd92
--- /dev/null
+++ b/results/scraper/box64/2598
@@ -0,0 +1,33 @@
+Should `NewBrick()` use `setProtection_mmap` to correctly track mmap regions?
+In `NewBrick()`, after allocating memory via `box_mmap()`, the code currently uses `setProtection()`:
+```c
+brick_t* NewBrick(void* old)
+{
+    brick_t* ret = (brick_t*)box_calloc(1, sizeof(brick_t));
+    static void* load_addr_32bits = NULL;
+    if(box64_is32bits)
+        old = load_addr_32bits;
+    else {
+        if(old)
+            old = old + NBRICK * sizeof(onebridge_t);
+    }
+    void* ptr = box_mmap(old, NBRICK * sizeof(onebridge_t), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | ((!box64_is32bits && box64_wine)?0:0x40) | MAP_ANONYMOUS, -1, 0); // 0x40 is MAP_32BIT
+    if(ptr == MAP_FAILED)
+        ptr = box_mmap(NULL, NBRICK * sizeof(onebridge_t), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | ((!box64_is32bits && box64_wine)?0:0x40) | MAP_ANONYMOUS, -1, 0);
+    if(ptr == MAP_FAILED) {
+        printf_log(LOG_NONE, "Warning, cannot allocate 0x%lx aligned bytes for bridge, will probably crash later\n", NBRICK*sizeof(onebridge_t));
+    }
+    setProtection((uintptr_t)ptr, NBRICK * sizeof(onebridge_t), PROT_READ | PROT_WRITE | PROT_EXEC | PROT_NOPROT);
+    dynarec_log(LOG_INFO, "New Bridge brick at %p (size 0x%zx)\n", ptr, NBRICK*sizeof(onebridge_t));
+    if(box64_is32bits) load_addr_32bits = ptr + NBRICK*sizeof(onebridge_t);
+    ret->b = ptr;
+    return ret;
+}
+```
+
+However, `setProtection()` does not label the region as `MEM_MMAP`. 
+As a result, `getMmapped()` returns 0, even though the region was mmap-allocated.
+
+I've already pushed a [local commit](https://github.com/devarajabc/box64/commit/0a2042a427c3bf6eaffa88124a84930a18126d06) that applies this change. 
+
+Before opening a PR, I’d like to confirm: Are there any design considerations that explain why `setProtection()` was originally used instead of `setProtection_mmap()`?
\ No newline at end of file