[DragonFlyBSD - Bug #3114] Using malloc(size_max) gives strange results

bugtracker-admin at leaf.dragonflybsd.org bugtracker-admin at leaf.dragonflybsd.org
Wed Dec 20 15:32:20 PST 2017


Issue #3114 has been updated by ddegroot.


I have had a look at the libc/stdlib/malloc.c code, and came to the conclusion that i would not be able to create a patch that would definitively fix this type of malloc/calloc/realloc issue.

An interesting link, regarding other allocators and this exact same issue: http://kqueue.org/blog/2012/03/05/memory-allocator-security-revisited/. This might provide some inspiration and potential test cases.

----------------------------------------
Bug #3114: Using malloc(size_max) gives strange results
http://bugs.dragonflybsd.org/issues/3114#change-13353

* Author: ddegroot
* Status: New
* Priority: Normal
* Assignee: 
* Category: Userland
* Target version: 5.0.0
----------------------------------------
While porting d-lang dmd/druntime/phobos to DragonFlyBSD, it became apparent that using 'malloc(size_t)' to deduce malloc and alignment rules, gave some unexpected results.

Example:
malloc size:9223372036854775807, malloc failed, ptr == NULL, errno:12                       // expected result (INTPTR_MAX)
malloc size:72036854775808,  ptr == 0x800800000                                             // this is fine
malloc size:18446744073709551613,  ptr == 0x800455000                                       // unexpected UINTPTR_MAX / SIZE_MAX

Related dlang:druntime PR: https://github.com/dlang/druntime/pull/1999

---Files--------------------------------
test_malloc.c (1.01 KB)
test_malloc_results.txt (1.97 KB)


-- 
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account



More information about the Bugs mailing list