# Bug in ngx\_slab.c?

**URL:** <https://www.ruby-forum.com/t/bug-in-ngx-slab-c/183042>\
**Category:** NGINX\
**Created:** [February 6, 2010, 8:21pm UTC](https://www.ruby-forum.com/t/bug-in-ngx-slab-c/183042 "2010-02-06T20:21:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 6, 2010, 8:21pm UTC](https://www.ruby-forum.com/t/bug-in-ngx-slab-c/183042/1 "2010-02-06T20:21:07Z")

</div>

Hello,

In “ngx\_slab.c”:

static ngx\_uint\_t ngx\_slab\_max\_size;  
[…]  
void ngx\_slab\_init(ngx\_slab\_pool\_t \*pool)  
{  
if (ngx\_slab\_max\_size == 0) {

Could one be sure, that “ngx\_slab\_max\_size” is always “0”?  
Maybe better:

static ngx\_uint\_t ngx\_slab\_max\_size = 0;

Thanks  
Marcus

Posted at Nginx Forum:

> **[Bug in ngx\_slab.c ?](https://forum.nginx.org/read.php?2,51479,51479#msg-51479)**
>
> Hello, In "ngx\_slab.c": \[code\] static ngx\_uint\_t ngx\_slab\_max\_size; \[...\] void ngx\_slab\_init(ngx\_slab\_pool\_t \*pool) { if (ngx\_slab\_max\_size == 0) { \[/code\] Could one be sure, that "ngx\_slab\_max

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 6, 2010, 10:45pm UTC](https://www.ruby-forum.com/t/bug-in-ngx-slab-c/183042/2 "2010-02-06T22:45:08Z")

</div>

Hello!

On Sat, Feb 06, 2010 at 02:20:36PM -0500, double wrote:

> Could one be sure, that “ngx\_slab\_max\_size” is always “0”?  
> Maybe better:
> 
> static ngx\_uint\_t ngx\_slab\_max\_size = 0;

Here is the explication from ISO C standard (6.7.8 Initialization):

% 10. If an object that has automatic storage duration is not  
initialized  
% explicitly, its value is indeterminate. If an object that has static  
storage  
% duration is not initialized explicitly, then:  
%  
% â€” if it has pointer type, it is initialized to a null pointer;  
% â€” if it has arithmetic type, it is initialized to (positive or  
unsigned)  
% zero;  
% â€” if it is an aggregate, every member is initialized (recursively)  
according  
% to these rules;  
% â€” if it is a union, the first named member is initialized  
(recursively)  
% according to these rules.

Guess which storage duration ngx\_slab\_max\_size has? If in doubt,  
refer to “6.2.4 Storage durations of objects” chapter of the same  
standard.

Maxim D.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 7, 2010, 9:41am UTC](https://www.ruby-forum.com/t/bug-in-ngx-slab-c/183042/3 "2010-02-07T09:41:42Z")

</div>

Thanks for pointing out!  
Didn’t know that.  
Marcus

Posted at Nginx Forum:

> **[Re: Bug in ngx\_slab.c ?](https://forum.nginx.org/read.php?2,51479,51631#msg-51631)**
>
> Hello, In "ngx\_slab.c": \[code\] static ngx\_uint\_t ngx\_slab\_max\_size; \[...\] void ngx\_slab\_init(ngx\_slab\_pool\_t \*pool) { if (ngx\_slab\_max\_size == 0) { \[/code\] Could one be sure, that "ngx\_slab\_max
