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

Bug report: Simple regular expression causing stack overflow in ippsRegExpFind_8u

Wjatschesl_H_Intel
284 Views

Hi there,

I have a simple example below with which you can reproduce the problem:

#include "stdafx.h"
#include <string>
#include <regex>

#define _IPP_SEQUENTIAL_STATIC
#include "ipp/include/ippch.h"

using std::tr1::regex;
using std::tr1::smatch;
using std::tr1::regex_match;

int _tmain(int argc, _TCHAR* argv[])
{
 IppStatus status;

 std::string input;
 input += "/*!";

 for (int i = 0; i < 40 * 1024; ++i)
 {
  // random data
  input += 'a' + (i % 26);
 }

 input += "*/";

 const char* pattern = "\\/\\*\\!([\\s\\S]*)\\*\\/";

 // std::regex example
 regex  rx(pattern);
 smatch matches;
 regex_match(input, matches, rx);

 int regExpStateSize = 0;
 status = ippsRegExpGetSize(pattern, &regExpStateSize);

 IppRegExpState* pRegExpState = (IppRegExpState*)malloc(regExpStateSize);
 int errOffs = 0;

 status = ippsRegExpInit(pattern, NULL, pRegExpState, &errOffs);

 IppRegExpFind find[2];
 int numFind = 2;

 status = ippsRegExpFind_8u((const Ipp8u*)input.c_str(), input.length(), pRegExpState, find, &numFind);

 free(pRegExpState);

 return 0;
}

Is this the expected behaviour or did I miss something?

I also played with RegExpSetMatchLimit. I tried a limit of 2, with that the stack overflow was gone, but it didn't match anything. So this is no solution for me.

Thanks, Slawa

IPP version information
Package ID: w_comp_lib_2016.2.180
Package Contents: Intel(R) Inspector XE 2016 Update 2
Build Number: 450824

0 Kudos
1 Reply
Gennady_F_Intel
Moderator
284 Views

thanks Slawa, we see the similar results on our side too. We will check the problem and get back asap. 

0 Kudos
Reply