Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

aligned_memchr16ff is not #9

Closed
UnitedMarsupials-zz opened this issue Jul 15, 2016 · 3 comments
Closed

aligned_memchr16ff is not #9

UnitedMarsupials-zz opened this issue Jul 15, 2016 · 3 comments

Comments

@UnitedMarsupials-zz
Copy link
Contributor

UnitedMarsupials-zz commented Jul 15, 2016

The function assumes, its argument is properly aligned for casting it to __m128i const *. The assumption appears valid on FreeBSD/amd64, but on a 32-bit FreeBSD/i386 it causes core-dumps.

The below patch makes the function forego the SSE-trickery and always use memchr on i386:

+++ src/lepton/recoder.cc
@@ -99,5 +99,5 @@

 static bool aligned_memchr16ff(const unsigned char *local_huff_data) {
-#if 1
+#if !defined(__i386__)
     __m128i buf = _mm_load_si128((__m128i const*)local_huff_data);
     __m128i ff = _mm_set1_epi8(-1);

Are you normally building/testing on 32-bit systems? With this patch I no longer have crashes running the test suit, but 5 of the 40 tests still fail...

@danielrh
Copy link
Contributor

Really appreciate you noticing this... to be fair I've never tried this on a i386 system--but it sounds like if this code fails on x86 there's probably some aliasing assumption being violated here and it's worth checking out to make it more cross compatible! I may not have time to look at this for a few days, but I'll try to compile in 32 bit mode as soon as I can

@UnitedMarsupials-zz
Copy link
Contributor Author

UnitedMarsupials-zz commented Jul 15, 2016

Thanks for the quick response, Daniel. I just committed FreeBSD port of lepton, which has this -- and many other -- patches in it.
Although all of the self-tests succeed on FreeBSD/amd64, five are failing for me on i386. I'm attaching the test-suite.log.

Note, that none of my machines here have SSE4, so I had to patch lepton to be satisfied with SSE2 and SSSE3.

@danielrh
Copy link
Contributor

Fixed by c5fd505

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

No branches or pull requests

2 participants