1557 – std.zlib allocates void[]s instead of ubyte[]s, causing leaks.

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1557 - std.zlib allocates void[]s instead of ubyte[]s, causing leaks.
Summary: std.zlib allocates void[]s instead of ubyte[]s, causing leaks.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 normal
Assignee: Walter Bright
URL: http://www.digitalmars.com/webnews/ne...
Keywords:
Depends on:
Blocks:
Reported: 2007年10月08日 17:25 UTC by Frits van Bommel
Modified: 2014年02月24日 15:59 UTC (History)
1 user (show)

See Also:


Attachments
The patch mentioned in the initial report. (3.02 KB, patch)
2007年10月08日 17:26 UTC, Frits van Bommel
Details | Diff
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Frits van Bommel 2007年10月08日 17:25:51 UTC
std.zlib allocates buffers as void[]s instead of ubyte[]s. While in each instance std.gc.hasNoPointers is promptly called on the result, there are concatenations performed with void[] arrays and those don't preserve that attribute.
The URL entered is to a discussion of this bug in digitalmars.D, though it manifested in relation to GDC and I haven't verified a memory leak actually exists in the DMD version. However, the module is nearly identical and AFAIK the GC hasn't been upgraded since the version GDC was based on (1.020) either.
I'm attaching a patch against DMD 1.022 std.zlib with the following changes:
1) I changed all newly-allocated arrays to ubyte[] instead of void[].
2) I also took the opportunity to change some cast(ubyte*)s on those void[]s to uses of the .ptr property.
3) std.gc.hasNoPointers() is no longer needed; I removed all calls to it and removed the import.
I haven't extensively tested correctness. However this patch is rather trivial, the changed code compiles and the unit test succeeds so I don't think I could've broken anything.
Comment 1 Frits van Bommel 2007年10月08日 17:26:51 UTC
Created attachment 190 [details] 
The patch mentioned in the initial report.
Comment 2 Walter Bright 2007年11月03日 21:48:22 UTC
Fixed dmd 1.023 and 2.007


AltStyle によって変換されたページ (->オリジナル) /