]>
Commit | Line | Data |
---|---|---|
53b567d6 | 1 | # DP: Throw exception instead of aborting when out of memory |
2 | ||
3 | From: inaky@peloncho.fis.ucm.es | |
4 | To: submit@bugs.debian.org | |
5 | Subject: Bug#42622: libstdc++2.10-dev: stl_alloc.h: malloc_alloc out of memory handling abort()s instead of using exceptions | |
6 | Date: Sat, 7 Aug 1999 04:31:58 +0200 | |
7 | ||
8 | Package: libstdc++2.10-dev | |
9 | Version: 1:2.95-2 | |
10 | Severity: important | |
11 | ||
12 | Hi | |
13 | ||
14 | While coding some proof-of-concepts I've come around using a | |
15 | vector<> of a big lot of elements. Wanted to push the limits and try | |
16 | to recover possible failures. No way. The program was aborting on the | |
17 | library's own. | |
18 | ||
19 | That should not do. You want exceptions to be able to dictate | |
20 | how the program should behave on error situations. The thing is at | |
21 | stl_alloc.h, instead of throwing an exception on OOM, it was printing | |
22 | the message "out of memory" to stderr and aborting. It is also | |
23 | prepared for doing it via exceptions, so I think it should be the | |
24 | default way. | |
25 | ||
26 | I think that behaviour should be made extensible to the whole | |
27 | libstdc++ library, as as far as I know, exception support in GCC is | |
28 | mature enough as to handle it [and I hope so :)]. That's the only way | |
29 | to fully control a program's flow. Libraries should not dictate what | |
30 | to do on error [I'm sure I'm not telling you anything new]. | |
31 | ||
32 | The changes to make stl_alloc work ok with exceptions are: | |
33 | ||
34 | --- libstdc++/stl/stl_alloc.h~ Fri May 7 12:13:28 1999 | |
35 | +++ libstdc++/stl/stl_alloc.h Sat Aug 7 04:16:22 1999 | |
36 | @@ -38,7 +38,7 @@ | |
37 | // The allocation primitives are intended to allocate individual objects, | |
38 | // not larger arenas as with the original STL allocators. | |
39 | ||
40 | -#if 0 | |
41 | +#ifdef __STL_USE_EXCEPTIONS | |
42 | # include <new> | |
43 | # define __THROW_BAD_ALLOC throw bad_alloc() | |
44 | #elif !defined(__THROW_BAD_ALLOC) | |
45 | ||
46 | Thanks, anyway, for such nice packages for GCC & Co. | |
47 | ||
48 | Your happy Debian user, | |
49 | ||
50 | -- System Information | |
51 | Debian Release: potato | |
52 | Kernel Version: Linux jovian 2.2.7 #1 mar ago 3 02:24:40 CEST 1999 i586 unknown | |
53 | ||
54 | Versions of the packages libstdc++2.10-dev depends on: | |
55 | ii g++ 2.95-2 The GNU C++ compiler. | |
56 | ii libc6-dev 2.1.2-0pre4 GNU C Library: Development libraries and hea | |
57 | ii libstdc++2.10 2.95-2 The GNU stdc++ library |