[Issue 9449] Segmentation fault in main()

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 21 11:56:18 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9449



--- Comment #10 from John Colvin <john.loughran.colvin at gmail.com> 2013-04-21 19:56:15 BST ---
(In reply to comment #9)
> (In reply to comment #7)
> > I'm pretty sure the use of void[] in _memset128ii is simply so as to have a
> > 128bit data type. It's never used as, or expected to be, an array.
> > 
> > _memset128ii doesn't care whether it's being passed a static or dynamic array,
> > it just blindly increments a pointer and writes to it "count" times.
> 
> I think it does matter whether dynamic array was passed or a static one due to
> how arguments are passed.

It doesn't matter in this case because it is a pointer being passed, not an
array at all.

> > (In reply to comment #3)
> > > _memset128ii expects:
> > > 
> > > %rcx => size_t count
> > > %rdx => .ptr of value array
> > > $rsi => .length of value array
> > > %rdi => pointer to first argument array 
> > 
> > This is incorrect. _memset128 expects:
> > 
> > RCX: size_t count
> > RDX: higher 64 bits of value
> > RSI: lower 64 bits of value
> > RDI: pointer to the 1st element of the destination array.
> 
> I see no difference between length dynamic array property and your "lower 64
> bits of value" (also between ptr and "higher 64 bits of value"). 

because value is not an array. As I said before, void[] is just used because
conveniently void[].sizeof == 16 (128 bits) on x64 (the check for x64 is done
inside e2ir.c)

> And passing a
> pointer to dynamic array is not the same thing as passing pointer to the first
> element: http://dpaste.dzfl.pl/8f91aed8

See my comment above. Each *element* of the array is being represented by a
void[]. There is no D style array passing happening here, static or otherwise,
it's just pointers.

Imagine replacing void[] with a hypothetical _128BitType and you'll see what I
mean.

I'm currently re-implementing memset.d and updating the compiler to interact
with the new functions. This should hopefully fix this bug and maybe 9969 also,
if there isn't a nasty backend bug hiding behind it all.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list