Welcome! Log In Create A New Profile

Advanced

Re: {module dev}include <sys/time.h> on 32bit linux cause segmentation fault?

May 26, 2011 01:20AM
On Thu, May 26, 2011 at 11:36:42AM +0800, Conan wrote:
> hi, I'm wring a nginx module which is hooked at
> NGX_HTTP_ACCESS_PHASE. Segmentation fault happened when calling
> ngx_log_error(NGX_LOG_ERR, r->connection->log, "xxx") in my module's
> handler(which will handle every request). I found r->connection->log = 0x0
> when debug with gdb.
>
> On 64bit centos/ubuntu/macos module works well. Segmentation fault seem
> only occurs on 32bit linux(ubuntu).
>
> When I comment out #include <sys/time.h>, segmentation fault disappeared.
> Attachment is my module's skeleton.

> #include <sys/time.h>
> #include <ngx_config.h>
> #include <ngx_core.h>
> #include <ngx_http.h>

You should not include any files before ngx_config.h.
src/os/unix/ngx_linux_config.h does it for you:

#define _FILE_OFFSET_BITS 64

#include <sys/types.h>
#include <sys/time.h>

I believe, <sys/time.h> includes another file (may be <sys/types.h>
which depends on _FILE_OFFSET_BITS and your module is built with
32-bit off_t on 32-bit platform while nginx is build with 64-bit off_t.


--
Igor Sysoev

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

{module dev}include <sys/time.h> on 32bit linux cause segmentation fault? Attachments

Conan 2655 May 25, 2011 11:38PM

Re: {module dev}include <sys/time.h> on 32bit linux cause segmentation fault?

Igor Sysoev 1299 May 26, 2011 01:20AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 232
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready