Forum: NGINX Modules behaving differently on 32-bit and 64-bit systems?

2974d09ac2541e892966b762aad84943?d=identicon&s=25 andrewc (Guest)
on 2013-10-21 07:14
(Received via mailing list)
Hi there,

I have built nginx 1.5.6 from source, with a 3rd party module (xtoken -
http://code.google.com/p/nginx-xtoken-module/).

I have it working fine on a 32-bit Debian Squeeze system. An identical
build
on a 64-bit Centos 6.4 system, with an identical configuration file
results
in the error: "nginx: [crit] ngx_slab_alloc() failed: no memory" on
startup.

I have narrowed the problem to the xtoken module, in as much as removing
references to it on the 64-bit system results in nginx starting
correctly.

I have had a quick look at the module source code, and can't see
anything
that is obviously 32-bit -centric, other than a couple of variables that
have been declared as uint32_t.

Is it correct to assume that a properly written module will work
correctly
on both 32 and 64-bit systems?
Is there any additional nginx configuration that needs to be performed
on
64-bit systems?

Thanks,

Andrew

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,243883,243883#msg-243883
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2013-10-21 13:14
(Received via mailing list)
Hello!

On Mon, Oct 21, 2013 at 01:13:56AM -0400, andrewc wrote:

> I have narrowed the problem to the xtoken module, in as much as removing
> references to it on the 64-bit system results in nginx starting correctly.
>
> I have had a quick look at the module source code, and can't see anything
> that is obviously 32-bit -centric, other than a couple of variables that
> have been declared as uint32_t.
>
> Is it correct to assume that a properly written module will work correctly
> on both 32 and 64-bit systems?

Yes.

> Is there any additional nginx configuration that needs to be performed on
> 64-bit systems?

In some cases, additional configuration may be required due to
different data sizes.

Quick looks suggests that the problem in xtoken module is likely
here:

https://code.google.com/p/nginx-xtoken-module/sour...

It tries to estimate size of shared memory zone needed to keep
it's data, but the estimate likely fails on 64-bit platforms due
to internal structures of slab allocator being bigger on these
platforms.

The same code may also unexpectedly fail in the future on internal
slab allocator changes.

--
Maxim Dounin
http://nginx.org/en/donation.html
2974d09ac2541e892966b762aad84943?d=identicon&s=25 andrewc (Guest)
on 2013-10-22 04:35
(Received via mailing list)
Maxim Dounin Wrote:
-------------------------------------------------------

> Quick looks suggests that the problem in xtoken module is likely
> here:
>
> https://code.google.com/p/nginx-xtoken-module/sour...
> http_xtoken_module.c#660
>
> It tries to estimate size of shared memory zone needed to keep
> it's data, but the estimate likely fails on 64-bit platforms due
> to internal structures of slab allocator being bigger on these
> platforms.

Thanks for the tip, Maxim. On line 13 of ngx_http_token_module.c I
replaced:

#define XTOKEN_SHM_SIZE    (sizeof(ngx_http_xtoken_shctx_t))

with:

#define XTOKEN_SHM_SIZE 65536

and rebuilt. It seems to work fine now.

65536 is purely arbitrary, and obviously not the most efficient use of
memory. I'll do some reading and see if I can rework that memory
allocation
line.

Thanks,

Andrew

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,243883,243943#msg-243943
2974d09ac2541e892966b762aad84943?d=identicon&s=25 danielf (Guest)
on 2014-05-26 09:39
(Received via mailing list)
Sorry if im bumping a very old thread but was a more permanent solution
ever
found to this problem?

//Daniel F

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,243883,250353#msg-250353
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.