# Two little bugs

**URL:** <https://www.ruby-forum.com/t/two-little-bugs/200212>\
**Category:** NGINX\
**Created:** [December 7, 2010, 7:47am UTC](https://www.ruby-forum.com/t/two-little-bugs/200212 "2010-12-07T07:47:30Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 7, 2010, 7:47am UTC](https://www.ruby-forum.com/t/two-little-bugs/200212/1 "2010-12-07T07:47:30Z")

</div>

I find two little bugs. Don’t know whether others mentioned or not.

1. if the argument of nginx -c is a relative path, it wil trigger a  
segment fault. Meant to be implemented like that? Because since 0.5.x to  
current release contain this bug.

2. In nginx 0.9.x, the man is also “nginx 8”. Meant to upgrade in some  
following revision?

Posted at Nginx Forum:

> **[Two little bugs](https://forum.nginx.org/read.php?2,156312,156312#msg-156312)**
>
> I find two little bugs. Don't know whether others mentioned or not. 1. if the argument of nginx -c is a relative path, it wil trigger a segment fault. Meant to be implemented like that? Because since 0.5.x to current release contain this bug. 2. In...

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [December 7, 2010, 8:10am UTC](https://www.ruby-forum.com/t/two-little-bugs/200212/2 "2010-12-07T08:10:03Z")

</div>

Hi,

On Tue, Dec 07, 2010 at 01:45:53AM -0500, speedfirst wrote:

> I find two little bugs. Don’t know whether others mentioned or not.
> 
> 1. In nginx 0.9.x, the man is also “nginx 8”. Meant to upgrade in some  
> following revision?

this is not the bug and ``8’’ is not version number.

See [man page - Wikipedia](http://en.wikipedia.org/wiki/Man_page#Manual_sections)  
as well as [man page - Wikipedia](http://en.wikipedia.org/wiki/Man_page) for details.

–  
Sergey A. Osokin  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [December 7, 2010, 8:39am UTC](https://www.ruby-forum.com/t/two-little-bugs/200212/3 "2010-12-07T08:39:30Z")

</div>

On Tue, Dec 07, 2010 at 01:45:53AM -0500, speedfirst wrote:

> I find two little bugs. Don’t know whether others mentioned or not.
> 
> 1. if the argument of nginx -c is a relative path, it wil trigger a  
> segment fault. Meant to be implemented like that? Because since 0.5.x to  
> current release contain this bug.

Could you show a test case ?  
I can not reproduce the issue.

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [December 8, 2010, 7:14am UTC](https://www.ruby-forum.com/t/two-little-bugs/200212/4 "2010-12-08T07:14:23Z")

</div>

On Wed, Dec 8, 2010 at 7:36 AM, speedfirst [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> nginx/sbin/nginx -c nginx.conf  
> [/code]
> 
> will get segment fault

I can’t reproduce this either. Please provide output of nginx/sbin/nginx  
-V

–  
O\< ascii ribbon campaign - stop html mail - [www.asciiribbon.org](http://www.asciiribbon.org)

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [December 8, 2010, 1:37am UTC](https://www.ruby-forum.com/t/two-little-bugs/200212/5 "2010-12-08T01:37:53Z")

</div>

For example,

```auto
nginx/sbin/nginx -c /opt/nginx/nginx.conf
```

is OK, because /opt/nginx/nginx.conf is an absolute path

However,

```auto
nginx/sbin/nginx -c nginx.conf
```

will get segment fault

I debug the source code, the problem is located in the function  
“ngx\_conf\_full\_name”. Seems the cycle used in that function is not yet  
initialized when trying to get the full path.

Posted at Nginx Forum:

> **[Re: Two little bugs](https://forum.nginx.org/read.php?2,156312,156602#msg-156602)**
>
> I find two little bugs. Don't know whether others mentioned or not. 1. if the argument of nginx -c is a relative path, it wil trigger a segment fault. Meant to be implemented like that? Because since 0.5.x to current release contain this bug. 2. In...

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [December 8, 2010, 4:53pm UTC](https://www.ruby-forum.com/t/two-little-bugs/200212/6 "2010-12-08T16:53:49Z")

</div>

On Tue, 7 Dec 2010 10:38:26 +0300, Igor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 1. if the argument of nginx -c is a relative path, it wil trigger a  
> > segment fault. Meant to be implemented like that? Because since  
> > 0.5.x to current release contain this bug.
> 
> Could you show a test case ?  
> I can not reproduce the issue.

While using Ubuntu 10.10+Nginx 0.8.53

1. using full path works:  
sudo nginx -c /etc/nginx/nginx.conf

2. using relative path fails:  
sudo nginx -c nginx.conf  
with error:  
[emerg]: open() “/usr/local/nginx/nginx.conf” failed (2: No such file  
or directory)

As seen bellow, my --conf-path=/etc/nginx/nginx.conf.  
Why is nginx trying to open it at /usr/local/nginx/nginx.conf?  
Is it hard wired at some other place in the code?

Regards,

M.

$ nginx -V  
nginx version: nginx0.8.53  
TLS SNI support enabled  
configure arguments: --conf-path=/etc/nginx/nginx.conf  
–error-log-path=/var/log/nginx/error.log  
–http-client-body-temp-path=/var/lib/nginx/body  
–http-fastcgi-temp-path=/var/lib/nginx/fastcgi  
–http-log-path=/var/log/nginx/access.log  
–http-proxy-temp-path=/var/lib/nginx/proxy  
–lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid  
–with-http\_ssl\_module --without-http\_limit\_req\_module  
–without-mail\_pop3\_module --without-mail\_smtp\_module  
–without-mail\_imap\_module --without-http\_uwsgi\_module  
–without-http\_scgi\_module --without-http-cache

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [December 8, 2010, 5:05pm UTC](https://www.ruby-forum.com/t/two-little-bugs/200212/7 "2010-12-08T17:05:45Z")

</div>

Hi,

> 1. using relative path fails:  
> sudo nginx -c nginx.conf  
> with error:  
> [emerg]: open() “/usr/local/nginx/nginx.conf” failed (2: No such file  
> or directory)

It’s supposed to fail.

> As seen bellow, my --conf-path=/etc/nginx/nginx.conf.  
> Why is nginx trying to open it at /usr/local/nginx/nginx.conf?  
> Is it hard wired at some other place in the code?

Because you’re passing only filename.

Skip -c option if you want to use path from build-time conf-path.

Best regards,  
Piotr S. \< [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) \>

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [December 8, 2010, 6:31pm UTC](https://www.ruby-forum.com/t/two-little-bugs/200212/8 "2010-12-08T18:31:03Z")

</div>

On Wed, 8 Dec 2010 17:04:40 +0100, “Piotr S.”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 1. using relative path fails:  
> > sudo nginx -c nginx.conf  
> > with error:  
> > [emerg]: open() “/usr/local/nginx/nginx.conf” failed (2: No such  
> > file or directory)
> 
> It’s supposed to fail.

How come?

I we have defined --conf-path=/etc/nginx/nginx.conf and that file  
exists at that place;  
I would expect that in case of any trouble at opening the  
config file stated in the command line,  
be it ‘nginx -c nginx.conf’ or ‘nginx  
-c /whatever/path/anyfile-nginx.conf’,  
nginx would try an [emerg]: open() “/etc/nginx/nginx.conf”,  
not, as it is doing now, an [emerg]: open()  
“/usr/local/nginx/nginx.conf”

> > As seen bellow, my --conf-path=/etc/nginx/nginx.conf.  
> > Why is nginx trying to open it at /usr/local/nginx/nginx.conf?  
> > Is it hard wired at some other place in the code?
> 
> Because you’re passing only filename.

It shouldn’t matter.  
For the sake of portability in whatever filesystem it happens to be,  
if in trouble, nginx should look for the config file stated at  
–conf-path= not at some pre-wired location, be it /usr/local/nginx/ or  
whatever.

Best regards,

M.

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [December 8, 2010, 6:43pm UTC](https://www.ruby-forum.com/t/two-little-bugs/200212/9 "2010-12-08T18:43:34Z")

</div>

Hello!

On Wed, Dec 08, 2010 at 05:29:07PM +0000, Mark A. wrote:

> How come?
> 
> I we have defined --conf-path=/etc/nginx/nginx.conf and that file  
> exists at that place;  
> I would expect that in case of any trouble at opening the  
> config file stated in the command line,  
> be it ‘nginx -c nginx.conf’ or ‘nginx  
> -c /whatever/path/anyfile-nginx.conf’,  
> nginx would try an [emerg]: open() “/etc/nginx/nginx.conf”,  
> not, as it is doing now, an [emerg]: open()  
> “/usr/local/nginx/nginx.conf”

Relative path in -c is resolved from --prefix, that’s why you see  
“/usr/local/nginx/” + “nginx.conf”.

Note that I don’t argue if it breaks POLA or not, it’s just how it  
currently works. I personally think that paths in command line  
arguments should be resolved from pwd.

Maxim D.

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [December 8, 2010, 6:47pm UTC](https://www.ruby-forum.com/t/two-little-bugs/200212/10 "2010-12-08T18:47:19Z")

</div>

Hi,

> It shouldn’t matter.

Yes, is should.

> For the sake of portability in whatever filesystem it happens to be,  
> if in trouble, nginx should look for the config file stated at  
> –conf-path= not at some pre-wired location, be it /usr/local/nginx/ or  
> whatever.

No, for 2 reasons:

1. “–conf-path” is path to a file, not a directory. It points to the  
default configuration and if you skip -c option then nginx _is_ using  
this  
file.
2. When you specify relative filename (nginx -c nginx.conf) then nginx  
is  
looking in directory specified during build in “–prefix”. For example,  
with  
“–prefix=/etc/nginx” (like it’s set in OpenBSD and FreeBSD ports),  
nginx -c  
nginx.conf is opening file from /etc/nginx/nginx.conf location.

Don’t blame nginx for your misuses.

Best regards,  
Piotr S. \< [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) \>

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [December 8, 2010, 8:01pm UTC](https://www.ruby-forum.com/t/two-little-bugs/200212/11 "2010-12-08T20:01:24Z")

</div>

On Wed, 8 Dec 2010 20:42:35 +0300, Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Relative path in -c is resolved from --prefix, that’s why you see  
> “/usr/local/nginx/” + “nginx.conf”.  
> Note that I don’t argue if it breaks POLA or not, it’s just how it  
> currently works.  
> I personally think that paths in command line  
> arguments should be resolved from pwd.

So do I.

Thank you Maxim.

M.

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [December 8, 2010, 9:43pm UTC](https://www.ruby-forum.com/t/two-little-bugs/200212/12 "2010-12-08T21:43:49Z")

</div>

On Wed, Dec 08, 2010 at 08:42:35PM +0300, Maxim D. wrote:

> > > > file or directory)  
> > > > -c /whatever/path/anyfile-nginx.conf’,  
> > > > nginx would try an [emerg]: open() “/etc/nginx/nginx.conf”,  
> > > > not, as it is doing now, an [emerg]: open()  
> > > > “/usr/local/nginx/nginx.conf”
> 
> Relative path in -c is resolved from --prefix, that’s why you see  
> “/usr/local/nginx/” + “nginx.conf”.
> 
> Note that I don’t argue if it breaks POLA or not, it’s just how it  
> currently works. I personally think that paths in command line  
> arguments should be resolved from pwd.

If nginx has been built with empty prefix, i.e, --prefix= then it uses  
pwd.

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [December 8, 2010, 10:31pm UTC](https://www.ruby-forum.com/t/two-little-bugs/200212/13 "2010-12-08T22:31:33Z")

</div>

Hello!

On Wed, Dec 08, 2010 at 11:42:48PM +0300, Igor S. wrote:

> > > > > with error:  
> > > > > config file stated in the command line,  
> > > > > currently works. I personally think that paths in command line  
> > > > > arguments should be resolved from pwd.
> 
> If nginx has been built with empty prefix, i.e, --prefix= then it uses pwd.

Yes. But I think command line arguments should use pwd regardless  
of prefix.

While resolving paths in config from prefix/conf\_prefix is  
somewhat convenient (though conf\_prefix semantics is questionable,  
too, it probably should always use dirname of current config  
instead) - using the same logic for command line arguments breaks  
POLA. People expect both

$ vi test-configs/nginx.conf

and

$ nginx -t -c test-configs/nginx.conf

to work with the same file.

Maxim D.

---

<div class="post-metadata">

**Author:** ![speedfirst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@speedfirst](https://www.ruby-forum.com/u/speedfirst)\
**Post date:** [December 9, 2010, 2:55am UTC](https://www.ruby-forum.com/t/two-little-bugs/200212/14 "2010-12-09T02:55:09Z")

</div>

## edogawaconan Wrote:

> On Wed, Dec 8, 2010 at 7:36 AM, speedfirst wrote:
> 
> > nginx/sbin/nginx -c nginx.conf
> > 
> > will get segment fault
> 
> I can’t reproduce this either. Please provide  
> output of nginx/sbin/nginx -V

Hey, I’m working on nginx dev for Zimbra. Here are my “-V” output.

```auto
speedfirst@u10:/opt/zimbra$ nginx/sbin/nginx -c conf/nginx.conf -V
nginx version: nginx/0.8.48
built by gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
TLS SNI support enabled
configure arguments: --prefix=/opt/zimbra/nginx-0.8-zimbra
--with-cc-opt='-g -I/opt/zimbra/cyrus-sasl-2.1.23.3z/include
-I/opt/zimbra/openssl-1.0.0a/include -I/opt/zimbra/include'
--with-ld-opt='-L/opt/zimbra/cyrus-sasl-2.1.23.3z/lib
-L/opt/zimbra/openssl-1.0.0a/lib -L/opt/zimbra/lib' --with-debug
--with-http_ssl_module --with-http_stub_status_module --with-pcre
--with-http_upstream_zmauth_module --with-mail --with-mail-sasl
--with-mail_ssl_module --error-log-path=/opt/zimbra/log/nginx.log
--http-log-path=/opt/zimbra/log/nginx.access.log
--http-client-body-temp-path=/opt/zimbra/data/tmp/nginx/client
--http-proxy-temp-path=/opt/zimbra/data/tmp/nginx/proxy
--http-fastcgi-temp-path=/opt/zimbra/data/tmp/nginx/fastcgi
```

And I try to use /opt/zimbra/conf/nginx.conf with the relative path.  
According to above comments, nginx uses “–prefix” so it should try to  
find /opt/zimbra/nginx-0.8.48/conf/nginx.conf. If not found, should  
report an [emerg] error, rather than segment fault. Did I make something  
wrong in build? Could I send the source I have to you to check?

```auto
speedfirst@u10:/opt/zimbra$ sudo nginx/sbin/nginx -c conf/nginx.conf
[sudo] password for speedfirst:
Segmentation fault
```

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,156312,157026#msg-157026](http://forum.nginx.org/read.php?2,156312,157026#msg-157026)
