Opened 11 years ago

Closed 11 years ago

#500 closed defect (invalid)

nginx segfaults on Solaris 11.1 x86 when compiled with -m64

Reported by: nginxbugger.myopenid.com Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.5.x
Keywords: Cc:
uname -a: SunOS solaris 5.11 11.1 i86pc i386 i86pc
nginx -V: nginx version: nginx/1.5.10
built by Sun C 5.12 SunOS_i386 Patch 148918-08 2013/10/18
configure arguments: --with-cc=/opt/solarisstudio12.3/bin/cc --with-cc-opt='-m64 -g' --with-ld-opt=-m64

Description

Hi,

nginx 1.5.10 segfaults on Solaris 11.1 x86/amd64 when compiled with -m64:

./configure --with-cc=/opt/solarisstudio12.3/bin/cc --with-cc-opt="-m64 -g" --with-ld-opt="-m64"
...
vi objs/Makefile
# remove -fast -xipo
gmake
...
cd objs
dbx nginx
(dbx) run -t
Running: nginx -t
(process id 25357)
signal SEGV (no mapping at the fault address) in ngx_time_update at line 83 in file "ngx_times.c"
   83       if (!ngx_trylock(&ngx_time_lock)) {
(dbx) where
=>[1] ngx_time_update(), line 83 in "ngx_times.c"
  [2] ngx_time_init(), line 69 in "ngx_times.c"
  [3] main(argc = 2, argv = 0xffff80ffbffff498), line 272 in "nginx.c"
(dbx) list
   83       if (!ngx_trylock(&ngx_time_lock)) {
   84           return;
   85       }
   86
   87       ngx_gettimeofday(&tv);
   88
   89       sec = tv.tv_sec;
   90       msec = tv.tv_usec / 1000;
   91
   92       ngx_current_msec = (ngx_msec_t) sec * 1000 + msec;

No segfault when compiling with -m32…

Change History (1)

comment:1 by Maxim Dounin, 11 years ago

Resolution: invalid
Status: newclosed

With the parameters you've supplied, nginx will assume it's building 32-bit binary and will use 32-bit assembler code for atomic instructions (src/os/unix/ngx_sunpro_x86.il), while 64-bit one is actually required (src/os/unix/ngx_sunpro_amd64.il). This expectedly results in problems.

Solution is to use --with-cpu-opt=amd64 instead of adding -m64 to ld/cc options manually, like this:

./configure --with-cc=/opt/solarisstudio12.3/bin/cc --with-cpu-opt=amd64

It will configure things correctly for you.

Note: See TracTickets for help on using tickets.