-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
A-allocatorsArea: Custom and system allocatorsArea: Custom and system allocatorsC-bugCategory: This is a bug.Category: This is a bug.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.Call for participation: Hard difficulty. Experience needed to fix: A lot.P-lowLow priorityLow priorityT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
Compare these two:
let v = vec![0u8; !0];
let u = vec![0u16; !0];
We request a vector with 18446744073709551615 elements.
- For
u8
we receive out of memory (null) from the allocator, and callalloc::oom
, which aborts the program:application terminated abnormally with signal 4 (Illegal instruction)
- For
u16
, we get an assertion:thread '<main>' panicked at 'capacity overflow', ../src/libcore/option.rs:330
This is inconsistent. Why don't we abort on both of these cases? We abort on too large allocation requests, so those that are even larger could abort too?
Metadata
Metadata
Assignees
Labels
A-allocatorsArea: Custom and system allocatorsArea: Custom and system allocatorsC-bugCategory: This is a bug.Category: This is a bug.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.Call for participation: Hard difficulty. Experience needed to fix: A lot.P-lowLow priorityLow priorityT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.