Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

access violation in ippiCopy_8u_C3P3R

JamesSmith
Novice
1,490 Views

I've got a strange access violation in the ippiCopy_8u_C3P3R function on special condition.

Calling the function below with a image-size of 1280 & an offset of 1 (as a starting point of a roi) crashes. The encountered error callstack : l9_owniCopy_8u_C3P3R_cn() l9_ippiCopy_8u_C3P3R()

Run the application by sde-external (8.63.0-2021-01-18-win) shows more details:

 

SDE ERROR:  TID: 0 executed instruction with an unaligned memory reference to address 0x225c13a7056 INSTR: 0x7ff6ee12829c: IFORM: VMOVNTDQ_MEMu32_YMMu32_AVX512 :: vmovntdq ymmword ptr [rax+r8*1], ymm19

 

The image Address dst[0] is 0x225c13a7040.

 

We could meld down the problem to the AVX2 call with IPP 2019, 2020, 2021. Running the code on older hardware (no AVX2) or with IPP 9.0 works fine.

 

Valid size are for example {3, 64, 91, 150, 640, 1279, 1281} with any offset e.g. {0, 1, 3, 5, 16, 32, 64, 128}

Invalid size are for example {1280, 1280 + 640, 5120} with an offset e.g. not {0, 32, 64, 128}

 

 

  void copy4pTest_Failure(const int size, const int offset)
  {
    IppiSize imageSize{ size, size };

    int stepHSV24;
    Ipp8u* pubHSV24 = ippiMalloc_8u_C3(imageSize.width, imageSize.height, &stepHSV24);

    int bufferOffset = 128;
    int stepDst[3];
    Ipp8u* dst[3];
    dst[0] = new unsigned char[imageSize.height * (imageSize.width + bufferOffset)];
    dst[1] = new unsigned char[imageSize.height * (imageSize.width + bufferOffset)];
    dst[2] = new unsigned char[imageSize.height * (imageSize.width + bufferOffset)];
    stepDst[0] = stepDst[1] = stepDst[2] = imageSize.width; // +bufferOffset;

    Ipp8u* dstRoi[3];
    dstRoi[0] = dst[0] + offset;
    dstRoi[1] = dst[1] + offset;
    dstRoi[2] = dst[2] + offset;

    IppiSize roi{ size, size };
    auto offsetMem = ((size_t) dst[0]) % 64;
    auto offsetMemRoi = ((size_t) dstRoi[0]) % 64;
    std::cout << "X Offset " << std::setw(3) << offset << " Mem Offset [ " << std::setw(3) << offsetMem << " " << std::setw(3) << offsetMemRoi << " ] Step "
               << std::setw(5) << stepDst[0] << std::setw(5) << " roi " << std::setw(5) << roi.width
               << " 0x" << std::hex << (size_t) dstRoi[0] << " img 0x" << std::hex << (size_t) dst[0] << std::endl;

    auto state = ippiCopy_8u_C3P3R(pubHSV24, stepHSV24, dstRoi, stepDst[0], roi);
    asserIppReturnCode(state);

    delete[] dst[0];   delete[] dst[1];   delete[] dst[2];
    ippiFree(pubHSV24);

 

 

 

Environment

  • IPP Version 2021.1.1, 2020.4.311, 2019.5.281, 9.0, Link static x64
  • Windows Version 10.0.17763 Build 17763
  • Prozessor Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz, 2592 MHz, 6 Kern(e), 
  • Visual Studio 2017 15.9.16 x64
Labels (1)
0 Kudos
4 Replies
JamesSmith
Novice
1,473 Views

On a real world problem we have the following crash

SDE ERROR:  TID: 0 executed instruction with an unaligned memory reference to address 0x2b4cc200490 INSTR: 0x7ff70d41829c: IFORM: VMOVNTDQ_MEMu32_YMMu32_AVX512 :: vmovntdq ymmword ptr [rax+r8*1], ymm19

With ImageSize of 1280,x1280 offset 0, step 1280 ; Image address 0x2b4cc200468

With other images Sizes e.g. {3, 5, 31, 64, 640, 1276, 1284} there is no problem

0 Kudos
AbhishekD_Intel
Moderator
1,469 Views

Hi,

 

Thanks for reaching out to us.

We are looking into this issue and will get back to you as soon as we get any updates related to this issue.

 

 

Warm Regards,

Abhishek

 

0 Kudos
Andrey_B_Intel
Employee
1,447 Views

Hi James.

I confirm this issue with ippiCopy_8u_C3P3R.

As workaround you can disable IPP AVX2 code in initialization section of your application:

    {
        Ipp64u features;
        ippInit();
        features = ippGetEnabledCpuFeatures();
        features &= (ippCPUID_AVX2 - 1);
        ippSetCpuFeatures(features);
    }

 But it affects performance of all subsequent calls of IPP functions.

The second workaround - to use only 64b aligned destination pointers.

We will fix this issue in one of next IPP releases.

Thanks.

Andrey B. 

JamesSmith
Novice
1,420 Views

Hi Andy,

thanks for your reply.

The 64b alignment helps, we plan to change this.

Disabling IPP AVX2 works but as you mentioned is not an option.

If the IPP Release 2021.2.0.210 should fix this bug, release note "Extended optimizations for Intel® IPP Image Processing and Color Coversions functions for selected algorithms for Intel® Advanced Vector Extensions 512 (Intel® AVX-512)." it doesn't fix the crash on our real-world scenario. Do you need more details?

I would expect, it shouldn't crash if the alignment is not as expected.

Thanks a lot for your investigation in this issue.

James S.

0 Kudos
Reply