# Pcre\_exec() failed: -10

**URL:** <https://www.ruby-forum.com/t/pcre-exec-failed-10/243935>\
**Category:** NGINX\
**Created:** [January 26, 2016, 5:34pm UTC](https://www.ruby-forum.com/t/pcre-exec-failed-10/243935 "2016-01-26T17:34:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [January 26, 2016, 5:34pm UTC](https://www.ruby-forum.com/t/pcre-exec-failed-10/243935/1 "2016-01-26T17:34:27Z")

</div>

Hello,

I’ve a rule below in nginx config to 404 if the argument of search query  
is  
a non printable ascii character. Nginx is compiled with pcre and pcre  
seem\*\* (refer 4.d below) to have utf8 support and unicode support  
enabled  
but nginx fails with “pcre\_exec() failed: -10” error when it encounters  
the  
regex.

Any pointers, please? Please refer below for more details.

TIA,

Krishna!

_1. from nginx config_

if ($args ~ “(_UTF8)^._[^\x21-\x7E].\*$”) {

```
     return 404;

 }

```

_…_

_2. from access log:_

54.169.206.188 [26/Jan/2016:20:29:10  
/search?userQuery=Taurm\xE9+Taurme+Corporate+Casual+Slip+On+Shoe+()

_3. from error log:_

2016/01/26 20:29:10 [alert] 27700#0: _43933484 on  
“userQuery=Taurm+Taurme+Corporate+Casual+Slip+On+Shoe+()” using  
"(UTF8)^.[^\x00-\x7F]._$", client: 54.169.206.188, server:  
[search.paytm.com](http://search.paytm.com), request: “GET  
/search?userQuery=Taurm+Taurme+Corporate+Casual+Slip+On+Shoe+()  
HTTP/1.1”,  
host: “[search.paytm.com](http://search.paytm.com)”

\*4. nginx and pcre \*

a) nginx -V

nginx version: openresty/1.7.2.1

b) ldd /usr/sbin/nginx|grep pcre

```
    lib*pcre*.so.3 => /lib/x86_64-linux-gnu/lib*pcre*.so.3

```

(0x00007fbdb64a7000)  
c) dpkg -l|grep pcre

ii lib_pcre_3:amd64 1:8.31-2ubuntu2.1  
amd64  
Perl 5 Compatible Regular Expression Library - runtime files

\*\*d) Since ubuntu no longer ships with pcretest, there was no easy way  
to  
see if utf8 support is enabled but from ubuntu package build logs for  
our  
version, I can see that is how it is built. Also, can confirm the same  
from  
config.log when building the debian package locally on my machine:

[https://launchpadlibrarian.net/212590020/buildlog\_ubuntu-trusty-amd64.pcre3\_1%3A8.31-2ubuntu2.1\_BUILDING.txt.gz](https://launchpadlibrarian.net/212590020/buildlog_ubuntu-trusty-amd64.pcre3_1%3A8.31-2ubuntu2.1_BUILDING.txt.gz)

---

<div class="post-metadata">

**Author:** ![Krishna\_PMV](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/7ea924/32.png) [@Krishna\_PMV](https://www.ruby-forum.com/u/Krishna_PMV)\
**Post date:** [January 26, 2016, 5:55pm UTC](https://www.ruby-forum.com/t/pcre-exec-failed-10/243935/2 "2016-01-26T17:55:29Z")

</div>

Hello!

On Tue, Jan 26, 2016 at 10:03:16PM +0530, Krishna PMV wrote:

> TIA,
> 
> 2016/01/26 20:29:10 [alert] 27700#0: _43933484 on  
> “userQuery=Taurm+Taurme+Corporate+Casual+Slip+On+Shoe+()” using  
> "(UTF8)^.[^\x00-\x7F]._$", client: 54.169.206.188, server:  
> [search.paytm.com](http://search.paytm.com), request: “GET  
> /search?userQuery=Taurm+Taurme+Corporate+Casual+Slip+On+Shoe+() HTTP/1.1”,  
> host: “[search.paytm.com](http://search.paytm.com)”

The error is returned by PCRE due to an invalid UTF-8 string being  
checked as UTF-8 one. Note “\xE9” in the access log entry. Some  
additional information can be found in the pcreunicode manpage.

–  
Maxim D.

> **[nginx](http://nginx.org/)**
