|
2005-10-19
| ||
| 09:20 | • Closed ticket [1259431fff]: Check for 0 byte allocation in ckalloc plus 6 ot... artifact: f43188c42e user: sf-robot | |
|
2005-10-05
| ||
| 07:01 | • Ticket [1259431fff]: 2 changes artifact: 3c066bd949 user: hobbs | |
| 07:01 | • Pending ticket [1259431fff]. artifact: 14ef48dae1 user: hobbs | |
|
2005-08-16
| ||
| 00:19 | • Ticket [1259431fff]: 4 changes artifact: 60f3b9d7e1 user: hobbs | |
| 00:19 | • Ticket [1259431fff]: 1 change artifact: cf1e89c3d3 user: hobbs | |
|
2005-08-15
| ||
| 22:03 | • Ticket [1259431fff]: 4 changes artifact: ad11bedadc user: dkf | |
| 08:33 | • Ticket [1259431fff]: 4 changes artifact: 3e8e8d281a user: mistachkin | |
| 08:03 | • Ticket [1259431fff]: 4 changes artifact: 1ffb3fea7b user: mdejong | |
| 08:03 | • Add attachment ckalloc.patch to ticket [1259431fff] artifact: 315aa588d8 user: mdejong | |
| 01:03 | • New ticket [1259431fff] Check for 0 byte allocation in ckalloc. artifact: 1fccfc45e9 user: mdejong | |
Check for 0 byte allocation in ckalloc
Closed / Wont Fix1259431fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2005-08-15 01:03:29
I ran into a little problem where a bug in code to call
ckalloc ended up trying to allocate 0 bytes. That
crashed in the Win32 malloc when compiled with
Mingw. I can't see any reason to allow a zero byte
allocation, and it seems like adding a test like the
following could not hurt. Any objections?
--- generic/tclCkalloc.c 19 Jan 2003 07:21:18
-0000 1.19
+++ generic/tclCkalloc.c 15 Aug 2005 00:59:24 -0000
@@ -373,6 +373,10 @@
if (validate_memory)
Tcl_ValidateAllMemory (file, line);
+ if (size == 0) {
+ panic("attempt to ckalloc 0 bytes, %s line
%d", size, file, line);
+ }
+
result = (struct mem_header *)
TclpAlloc((unsigned)size +
sizeof(struct
mem_header) + HIGH_GUARD_SIZE);
if (result == NULL) {
mdejongplain2005-08-15 08:03:29
File Added - 145666: ckalloc.patch
mistachkinplain2005-08-15 08:33:55
Logged In: YES user_id=113501 I don't think we should take this patch, it breaks compatibility with malloc(), which is technically allowed to allocate a "zero byte item" and return it. The ANSI C standard states that this is "implementation defined"; however, we should probably just treat it as a one byte request.
dkfplain2005-08-15 22:03:30
Logged In: YES user_id=79902 The core currently checks (in Tcl_Alloc()) to see whether a NULL low-level alloc result is coming from asking for zero bytes; if so, it *doesn't* panic. This indicates that panic-ing on zero-alloc is probably wrong.
hobbs Ticket [1259431fff]: 1 change
[History diff]2005-08-16 00:19:21
hobbsplain2005-08-16 00:19:22
Logged In: YES user_id=72656 We certainly shouldn't panic on 0 alloc requests - that is perfectly valid in the C standard. I see where Mo is requesting the patch we do seem to have a latent bug in that we shouldn't panic on (result == NULL) unless (size != 0), as AIX and some other systems do return NULL for 0-byte allocs. If a crash occured in the mingw compile, than I would backtrack to the sources making the alloc, as ckalloc(0)/malloc(0) is valid C. We did have to correct code in tkImg*.c once regarding this (0 size image allocs) because we simply weren't handling the case of such requests - which was a bug in the image code, not in ckalloc(0) per se.
hobbsplain2005-10-05 07:01:18
Logged In: YES user_id=72656 OK, this is the DB routines, and result == NULL panic is OK because we add guard bytes. IOW, if we don't get mem, we don't have any to get ....
hobbs Ticket [1259431fff]: 2 changes
[History diff]2005-10-05 07:01:19
sf-robotplain2005-10-19 09:20:53
Logged In: YES user_id=1312539 This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker).
Log in (anonymous is fine) to add a comment.
Attachments:
- ckalloc.patch [download] added by mdejong on 2005-08-15 08:03:29. [details]