# Invalid parsed value for keys\_zone. Is this a problem?

**URL:** <https://www.ruby-forum.com/t/invalid-parsed-value-for-keys-zone-is-this-a-problem/201944>\
**Category:** NGINX\
**Created:** [January 18, 2011, 2:37pm UTC](https://www.ruby-forum.com/t/invalid-parsed-value-for-keys-zone-is-this-a-problem/201944 "2011-01-18T14:37:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [January 18, 2011, 2:37pm UTC](https://www.ruby-forum.com/t/invalid-parsed-value-for-keys-zone-is-this-a-problem/201944/1 "2011-01-18T14:37:00Z")

</div>

Hi,

driven by a wrong undestand of proxy\_cache’s keys\_zone parameter I have  
set it to a very high value:

```auto
    proxy_cache_path /tmp/cache levels=2:2:2 keys_zone=cache:10000m
max_size=50g inactive=5m;
```

What happens is that 10G should be 10485760000, not 1895825408:

```auto
Breakpoint 3, ngx_http_file_cache_set_slot (cf=0xbfffef58,
cmd=0x80ee980, conf=0x0) at src/http/ngx_http_file_cache.c:1598
(gdb) p s
$1 = {len = 6, data = 0x811e2a3 "10000m"}
1598 size = ngx_parse_size(&s);
(gdb) p size
$2 = 1895825408
(gdb) n
1599 if (size > 8191) {
(gdb) n
1600 continue;
(gdb) quit
```

Even being an unreasonable value for in-memory cache, shouldn’t this  
unexpected result be avoided?

Posted at Nginx Forum:

> **[Invalid parsed value for keys\_zone. Is this a problem?](https://forum.nginx.org/read.php?2,167197,167197#msg-167197)**
>
> Hi, driven by a wrong undestand of proxy\_cache's keys\_zone parameter I have set it to a very high value: \[code\] proxy\_cache\_path /tmp/cache levels=2:2:2 keys\_zone=cache:10000m max\_size=50g inactive=5m; \[/code\] What happens is that 10G sh

---

<div class="post-metadata">

**Author:** ![caruccio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/258eb7/32.png) [@caruccio](https://www.ruby-forum.com/u/caruccio)\
**Post date:** [January 18, 2011, 3:30pm UTC](https://www.ruby-forum.com/t/invalid-parsed-value-for-keys-zone-is-this-a-problem/201944/2 "2011-01-18T15:30:27Z")

</div>

Hi,

On 18/01/2011 16:20, Igor S. wrote:

> 10485760000 is 0x271000000 in hex. On 32-bit platform it’s truncated to  
> 0x71000000, i.e., 1895825408. Yes, it should be checked.

Also, would it not be better to use off64\_t or some other larger type  
for storing the max\_size of the cache (or indeed for parsing off’s in  
general)? I’m not sure about all Posix systems, but on Debian off\_t is  
long int, hence a 32-bit value on 32-bit systems. I’ve not checked in  
the code, but I’m assuming that the max size of a file cache on 32-bit  
systems may then be 2GB.

Marcus.

---

<div class="post-metadata">

**Author:** ![caruccio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/258eb7/32.png) [@caruccio](https://www.ruby-forum.com/u/caruccio)\
**Post date:** [January 18, 2011, 3:22pm UTC](https://www.ruby-forum.com/t/invalid-parsed-value-for-keys-zone-is-this-a-problem/201944/3 "2011-01-18T15:22:17Z")

</div>

On Tue, Jan 18, 2011 at 08:35:10AM -0500, caruccio wrote:

> What happens is that 10G should be 10485760000, not 1895825408:  
> 1599 if (size \> 8191) {  
> (gdb) n  
> 1600 continue;  
> (gdb) quit  
> [/code]
> 
> Even being an unreasonable value for in-memory cache, shouldn’t this  
> unexpected result be avoided?

10485760000 is 0x271000000 in hex. On 32-bit platform it’s truncated to  
0x71000000, i.e., 1895825408. Yes, it should be checked.

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![caruccio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/258eb7/32.png) [@caruccio](https://www.ruby-forum.com/u/caruccio)\
**Post date:** [January 18, 2011, 3:42pm UTC](https://www.ruby-forum.com/t/invalid-parsed-value-for-keys-zone-is-this-a-problem/201944/4 "2011-01-18T15:42:23Z")

</div>

On Tue, Jan 18, 2011 at 04:29:16PM +0200, Eugaia wrote:

> the code, but I’m assuming that the max size of a file cache on 32-bit  
> systems may then be 2GB.

nginx uses 64-bit offsets on Linux with  
#define \_FILE\_OFFSET\_BITS 64

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![caruccio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/258eb7/32.png) [@caruccio](https://www.ruby-forum.com/u/caruccio)\
**Post date:** [January 18, 2011, 4:10pm UTC](https://www.ruby-forum.com/t/invalid-parsed-value-for-keys-zone-is-this-a-problem/201944/5 "2011-01-18T16:10:40Z")

</div>

On 18/01/2011 16:40, Igor S. wrote:

> > general)? I’m not sure about all Posix systems, but on Debian off\_t is  
> > long int, hence a 32-bit value on 32-bit systems. I’ve not checked in  
> > the code, but I’m assuming that the max size of a file cache on 32-bit  
> > systems may then be 2GB.  
> > nginx uses 64-bit offsets on Linux with  
> > #define \_FILE\_OFFSET\_BITS 64

Right.

Thanks,

Marcus.
