@@ -61,14 +61,16 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file)
6161 request_size += HUGE_PAGE_SIZE ;
6262#endif
6363
64- if ((size_t )request_size < size )
65- /* integer overflow */
64+ if ((size_t )request_size < size ) {
65+ os_printf ( "mmap failed: request size overflow due to paging\n" );
6666 return NULL ;
67+ }
6768
6869#if WASM_ENABLE_MEMORY64 == 0
69- if (request_size > 16 * (uint64 )UINT32_MAX )
70- /* at most 64 G is allowed */
70+ if (request_size > 16 * (uint64 )UINT32_MAX ) {
71+ os_printf ( "mmap failed: for memory64 at most 64G is allowed\n" );
7172 return NULL ;
73+ }
7274#endif
7375
7476 if (prot & MMAP_PROT_READ )
@@ -155,7 +157,7 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file)
155157
156158 if (addr == MAP_FAILED ) {
157159 os_printf ("mmap failed with errno: %d, hint: %p, size: %" PRIu64
158- ", prot: %d, flags: %d" ,
160+ ", prot: %d, flags: %d\n " ,
159161 errno , hint , request_size , map_prot , map_flags );
160162 return NULL ;
161163 }
@@ -268,6 +270,8 @@ os_mprotect(void *addr, size_t size, int prot)
268270 int map_prot = PROT_NONE ;
269271 uint64 page_size = (uint64 )getpagesize ();
270272 uint64 request_size = (size + page_size - 1 ) & ~(page_size - 1 );
273+ // printf("mprotect addr: %p, size: %llu, prot: %d\n", addr, request_size,
274+ // prot);
271275
272276 if (!addr )
273277 return 0 ;
@@ -281,12 +285,17 @@ os_mprotect(void *addr, size_t size, int prot)
281285 if (prot & MMAP_PROT_EXEC )
282286 map_prot |= PROT_EXEC ;
283287
288+ if (mprotect (addr , request_size , map_prot ) == -1 ) {
289+ printf ("mprotect failed\n" );
290+ }
291+
284292 return mprotect (addr , request_size , map_prot );
285293}
286294
287295void
288296os_dcache_flush (void )
289- {}
297+ {
298+ }
290299
291300void
292301os_icache_flush (void * start , size_t len )
0 commit comments