<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Bug report: Simple regular expression causing stack overflow in ippsRegExpFind_8u in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/Bug-report-Simple-regular-expression-causing-stack-overflow-in/m-p/1101401#M25166</link>
    <description>&lt;P&gt;&lt;SPAN style="font: 12px/12px Arial, 宋体, Tahoma, Helvetica, sans-serif; color: rgb(83, 87, 94); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; widows: 1; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"&gt;Hi there,&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;I have a simple example below with which you can reproduce the problem:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include "stdafx.h"
#include &amp;lt;string&amp;gt;
#include &amp;lt;regex&amp;gt;

#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[])
{
&amp;nbsp;IppStatus status;

&amp;nbsp;std::string input;
&amp;nbsp;input += "/*!";

&amp;nbsp;for (int i = 0; i &amp;lt; 40 * 1024; ++i)
&amp;nbsp;{
&amp;nbsp; // random data
&amp;nbsp; input += 'a' + (i % 26);
&amp;nbsp;}

&amp;nbsp;input += "*/";

&amp;nbsp;const char* pattern = "\\/\\*\\!([\\s\\S]*)\\*\\/";

&amp;nbsp;// std::regex example
&amp;nbsp;regex&amp;nbsp; rx(pattern);
&amp;nbsp;smatch matches;
&amp;nbsp;regex_match(input, matches, rx);

&amp;nbsp;int regExpStateSize = 0;
&amp;nbsp;status = ippsRegExpGetSize(pattern, &amp;amp;regExpStateSize);

&amp;nbsp;IppRegExpState* pRegExpState = (IppRegExpState*)malloc(regExpStateSize);
&amp;nbsp;int errOffs = 0;

&amp;nbsp;status = ippsRegExpInit(pattern, NULL, pRegExpState, &amp;amp;errOffs);

&amp;nbsp;IppRegExpFind find[2];
&amp;nbsp;int numFind = 2;

&amp;nbsp;status = ippsRegExpFind_8u((const Ipp8u*)input.c_str(), input.length(), pRegExpState, find, &amp;amp;numFind);

&amp;nbsp;free(pRegExpState);

&amp;nbsp;return 0;
}&lt;/PRE&gt;

&lt;P&gt;Is this the expected behaviour or did I miss something?&lt;/P&gt;

&lt;P&gt;I also played with RegExpSetMatchLimit. I tried a limit of 2, with that&amp;nbsp;the&amp;nbsp;stack overflow was gone, but it didn't match anything. So this is no solution for me.&lt;/P&gt;

&lt;P&gt;Thanks, Slawa&lt;/P&gt;

&lt;P&gt;IPP version information&lt;BR /&gt;
	Package ID: w_comp_lib_2016.2.180&lt;BR /&gt;
	Package Contents: Intel(R) Inspector XE 2016 Update 2&lt;BR /&gt;
	Build Number: 450824&lt;/P&gt;</description>
    <pubDate>Mon, 07 Mar 2016 13:25:04 GMT</pubDate>
    <dc:creator>Wjatschesl_H_Intel</dc:creator>
    <dc:date>2016-03-07T13:25:04Z</dc:date>
    <item>
      <title>Bug report: Simple regular expression causing stack overflow in ippsRegExpFind_8u</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Bug-report-Simple-regular-expression-causing-stack-overflow-in/m-p/1101401#M25166</link>
      <description>&lt;P&gt;&lt;SPAN style="font: 12px/12px Arial, 宋体, Tahoma, Helvetica, sans-serif; color: rgb(83, 87, 94); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; widows: 1; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"&gt;Hi there,&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;I have a simple example below with which you can reproduce the problem:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include "stdafx.h"
#include &amp;lt;string&amp;gt;
#include &amp;lt;regex&amp;gt;

#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[])
{
&amp;nbsp;IppStatus status;

&amp;nbsp;std::string input;
&amp;nbsp;input += "/*!";

&amp;nbsp;for (int i = 0; i &amp;lt; 40 * 1024; ++i)
&amp;nbsp;{
&amp;nbsp; // random data
&amp;nbsp; input += 'a' + (i % 26);
&amp;nbsp;}

&amp;nbsp;input += "*/";

&amp;nbsp;const char* pattern = "\\/\\*\\!([\\s\\S]*)\\*\\/";

&amp;nbsp;// std::regex example
&amp;nbsp;regex&amp;nbsp; rx(pattern);
&amp;nbsp;smatch matches;
&amp;nbsp;regex_match(input, matches, rx);

&amp;nbsp;int regExpStateSize = 0;
&amp;nbsp;status = ippsRegExpGetSize(pattern, &amp;amp;regExpStateSize);

&amp;nbsp;IppRegExpState* pRegExpState = (IppRegExpState*)malloc(regExpStateSize);
&amp;nbsp;int errOffs = 0;

&amp;nbsp;status = ippsRegExpInit(pattern, NULL, pRegExpState, &amp;amp;errOffs);

&amp;nbsp;IppRegExpFind find[2];
&amp;nbsp;int numFind = 2;

&amp;nbsp;status = ippsRegExpFind_8u((const Ipp8u*)input.c_str(), input.length(), pRegExpState, find, &amp;amp;numFind);

&amp;nbsp;free(pRegExpState);

&amp;nbsp;return 0;
}&lt;/PRE&gt;

&lt;P&gt;Is this the expected behaviour or did I miss something?&lt;/P&gt;

&lt;P&gt;I also played with RegExpSetMatchLimit. I tried a limit of 2, with that&amp;nbsp;the&amp;nbsp;stack overflow was gone, but it didn't match anything. So this is no solution for me.&lt;/P&gt;

&lt;P&gt;Thanks, Slawa&lt;/P&gt;

&lt;P&gt;IPP version information&lt;BR /&gt;
	Package ID: w_comp_lib_2016.2.180&lt;BR /&gt;
	Package Contents: Intel(R) Inspector XE 2016 Update 2&lt;BR /&gt;
	Build Number: 450824&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 13:25:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Bug-report-Simple-regular-expression-causing-stack-overflow-in/m-p/1101401#M25166</guid>
      <dc:creator>Wjatschesl_H_Intel</dc:creator>
      <dc:date>2016-03-07T13:25:04Z</dc:date>
    </item>
    <item>
      <title>thanks Slawa, we see the</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Bug-report-Simple-regular-expression-causing-stack-overflow-in/m-p/1101402#M25167</link>
      <description>&lt;P&gt;thanks Slawa, we see the similar results on our side too. We will check the problem and get back asap.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2016 10:18:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Bug-report-Simple-regular-expression-causing-stack-overflow-in/m-p/1101402#M25167</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2016-03-11T10:18:42Z</dc:date>
    </item>
  </channel>
</rss>

