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

AccessViolation exception in using ippiHistogram_32f_C1R



We are getting AccessViolationException in a call to ippiHistogram_32f_C1R every now and then, and it leads to a crash in our application. 

We're using Ipp 2019 Update 1, and here is the code (the line in bold leads to AccessViolationException). 

  • In HandleReturnValue, we check if the return value is different than 0, and if so we throw the proper exception.
  • img.Step is generated by a call to ippiMalloc_32f_C1. 

Could you point us to where the error might be?

public static uint[] Histogram(VMImage img, int band, float[] levels)
    short ippStatus = 0;
    int[] nLevels = { levels.Length };
    int sizeHistObj, sizeBuffer;
    IppiHistogramSpec* histSpec = null;
    byte* histBuffer = null;
    uint[] hist = new uint[levels.Length - 1];

    fixed (uint* pHist = &hist[0])
        fixed (float* pLevels0 = &levels[0])
            float*[] pLevels = { pLevels0 };
            fixed (float** ppLevels = &pLevels[0])
                // Get sizes for spec and buffer
                ippStatus = ippiHistogramGetBufferSize(IppDataType.ipp32f, img.GetRoiSize(), nLevels, 1/*nChan*/, 0/*user step*/, &sizeHistObj, &sizeBuffer);
                // Allocation of buffers
                histSpec = (IppiHistogramSpec*)ippsMalloc_8u(sizeHistObj);
                histBuffer = (byte*)ippsMalloc_8u(sizeBuffer);
                // Initialize spec
                ippStatus = ippiHistogramInit(IppDataType.ipp32f, ppLevels, nLevels, 1/*nChan*/, histSpec);
                // Calculate histogram
                ippStatus = ippiHistogram_32f_C1R((float*)img.GetRoiPointer(band), img.Step, img.GetRoiSize(), pHist, histSpec, histBuffer);

    // CleanUp
    if (histSpec != null)
    if (histBuffer != null)

    return hist;

0 Kudos
3 Replies

here is an unknown issue with IPP v.2019.  Do you see if the problem happens with some specific input images or it happens anytime? 

at the very first glance, everything looks as expected. We need to have a comprehensive example to build and run on our side.

0 Kudos

At the time of focusing on intel integrated performance primitives, I was facing some errors in my browser. The issue was regarding confirming form resubmission and again the issue was coming at the turning off of the confirmation. I tried to overcome the error. And I found that there was a very unique way to overcome this. If anybody faces the same issue of confirm form resubmission error in their browser, then he/she can browse to get a proper and easy solution.

0 Kudos
Hello, thank you for your issue. Could you please send more comprehensive code or explain in which cases you get this error? In this case I don't get same issue as you:

int main() {
	IppStatus status = ippStsNoErr;

	const int WIDTH   = 8;
	const int HEIGHT  = 8;
	const int nLevels = 5;

	int step;
	int specSize;
	int sizeBuffer;

	Ipp32f levels[nLevels] = { 0, 2, 4, 6, 13 };
	Ipp32f* pLevels        = &levels[0];

	IppiHistogramSpec* pSpec;

	Ipp8u*             pBuffer;

	Ipp32f*pSrc = ippiMalloc_32f_C1(WIDTH, HEIGHT, &step);
	Ipp32u pHist[nLevels - 1];

	IppiSize roiSize = { WIDTH, HEIGHT };

	status = ippiHistogramGetBufferSize(IppDataType::ipp32f, roiSize, &nLevels, 1, 0, &specSize, &sizeBuffer);
	print_status("ippiHistogramGetBufferSize", status);

	pSpec   = (IppiHistogramSpec*)ippsMalloc_8u(specSize);
	pBuffer = (byte*)ippsMalloc_8u(sizeBuffer);

	status = ippiHistogramInit(IppDataType::ipp32f, (const Ipp32f**)&pLevels, (int*)&nLevels, 1, pSpec);
	print_status("ippiHistogramInit", status);

	status = ippiHistogramGetLevels(pSpec, &pLevels);
	print_status("ippiHistogramGetLevels", status);

	status = ippiHistogram_32f_C1R(pSrc, step, roiSize, pHist, pSpec, pBuffer);
	print_status("ippiHistogram_32f_C1R", status);

	return 0;


0 Kudos