Project

General

Profile

Actions

Bug #3114

closed

Using malloc(size_max) gives strange results

Added by ddegroot about 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Userland
Target version:
Start date:
12/18/2017
Due date:
% Done:

0%

Estimated time:

Description

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.c malloc test c file ddegroot, 12/18/2017 09:25 AM
test_malloc_results.txt (1.97 KB) test_malloc_results.txt results from malloc test ddegroot, 12/18/2017 09:25 AM
nmalloc.c.diff (1.81 KB) nmalloc.c.diff diff against /lib/libc/stdlib/nmalloc.c ddegroot, 12/30/2017 04:21 PM
test_malloc.c (1.11 KB) test_malloc.c ddegroot, 12/31/2017 04:14 AM
Actions

Also available in: Atom PDF