http://d.puremagic.com/issues/show_bug.cgi?id=9092
[email protected] changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID | --- Comment #2 from [email protected] 2012-11-30 02:26:39 PST --- (In reply to comment #1) > I very much suspect that this is caused by the behaveour of large arrays that > need more space than 2048 bytes: these arrays store the actual allocated > length > at the beginning of the block and reserve 16 bytes for that, in contrast to > smaller arrays that place this information at the end of the memory block (see > druntime/src/rt/lifetime.d for details). > > So in your case, a.ptr does not point to the start of the memory block, but 16 > bytes into it, leaving a little less than the actual memory size for the > array. > GC.extend changes the memory block, but doesn't know about the > array-semantics, > so it reports back the raw size of the memory block. > > Your example mixes high level memory access (arrays) with low level functions > (GC.extend), I don't think that is a good idea. Instead, use GC.malloc for > your > first allocation. How could this possibly be "invalid"? "I don't think it is a good idea" is not the same as "This is wrong and invalid". I passed a pointer (a.ptr) to extend, and extend promised that memory location was extended to a certain amount. if a.ptr did not actually point to the beginning of a memory location, then why/how was it extended? And if extend was able to detect that a.ptr was already 16 bytes into my memory block, then why can't it take that into account when replying? Anyways, here is Appender subject to this bug... //---- void main() { auto a = new char[] (61000); auto app = appender!(char[])(a); foreach(k; 0..5000) { write(k, ' '); stdout.flush(); app.put('a'); } } //---- ... 4517 4518 4519 4520 object.Error: Access Violation //---- BTW, both these tests would appear to pass on DPaste, so the bug appears to be windows related. I guess such allocations on linux aren't a bad idea? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
