Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alignment issues #157

Closed
eskimor opened this issue Jan 12, 2013 · 5 comments
Closed

alignment issues #157

eskimor opened this issue Jan 12, 2013 · 5 comments

Comments

@eskimor
Copy link

eskimor commented Jan 12, 2013

The newly inserted align checks in the Allocater interface in memory.d fail for me.
I tested it with the GCAllocator, the AutoFreeListAllocator and even the manualAllocator.
It seems that GC.malloc does not return aligned data. Not 16 Byte aligned, not even 4 Byte aligned I had to change the mask down to 0x1 to make it work. The dlang.org documentation states that it returns aligned memory, but 2 Byte is a pretty low alignment.

Am I missing something? Do you experience the same issues?

@s-ludwig
Copy link
Member

I didn't have issues with the GCAllocator up to now and thus assumed that it returns aligned data. I have put in some manual alignment code there now in git head. But MallocAllocator should return aligned data since v0.7.10 and so should manualAllocator in turn... (although there was a problem that caused free() to crash on some systems)

Did the assertions trigger for you in the release version or on git head? The current state should now be that all Allocator derived classes should either pass on aligned data or manually align it.

@eskimor
Copy link
Author

eskimor commented Jan 13, 2013

Thanks! It seems to work now. I was using current HEAD. The alignment assertion triggered on GCAllocator, AutoFreeListAllocator (using the GCAllocator) and even with the manualAllocator. I am using a 64 bit system, if that matters.
If further investigation is desired and it helps, I could try the last released version. (I would have to backport some fixes, but it should not be too much work.)

@s-ludwig
Copy link
Member

The only thing I don't understand is the manualAllocator. But I don't assume that testing the release version would really give more insights, and I changed a lot of code now anyway, so let's just keep it at this.

Interestingly, I'm running 64-bit all the time on Linux and didn't have any problems there...

@eskimor
Copy link
Author

eskimor commented Jan 13, 2013

I am a bit confused now. I checked out the old version again, so I can tell you how to reproduce it, but now I can't reproduce it myself. Yesterday it triggered like always. It is the same thing all the time, someone tells you he can't reproduce it and suddenly you stop having issues. (Maybe just because of the reboot, memory is less corrupted so I get aligned one? Don't know.) I will keep running the old version and see if it happens again.

Why do you understand the issue for the GC allocator? Shouldn't it return aligned memory?

Regardless, the issue seems to be fixed, so if no further investigation is desired, feel free to close this issue.

And thanks for this very fast fix!

@s-ludwig
Copy link
Member

Just because the GCAllocator originally had no alignment code, as GC.malloc() always returned aligned memory for me. But since the documentation states that it is not aligned (at least not to 16 bytes), it's clear that the alignment code was needed (that I added only after you opened the report).

Alright, I'll close this then for now. Due to the amount of changes and testing I did yesterday, I don't really feel like hunting this "ghost" down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants