Modules behaving differently on 32-bit and 64-bit systems?

Hi there,

I have built nginx 1.5.6 from source, with a 3rd party module (xtoken -
Google Code Archive - Long-term storage for Google Code Project Hosting.).

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:

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/source/browse/trunk/ngx_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.

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


Maxim D.
http://nginx.org/en/donation.html

Maxim D. Wrote:

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

Google Code Archive - Long-term storage for Google Code Project Hosting.
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:

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: