Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c > #744 > unrolled thread

what may make the address of the member of the argument changed when doing function call?

Started bystefan <pengli.hust@gmail.com>
First post2011-08-02 07:10 -0700
Last post2011-08-24 05:10 -0700
Articles 5 — 4 participants

Back to article view | Back to comp.std.c


Contents

  what may make the address of the member of the argument changed when doing function call? stefan <pengli.hust@gmail.com> - 2011-08-02 07:10 -0700
    Re: what may make the address of the member of the argument changed when doing function call? James Kuyper <jameskuyper@verizon.net> - 2011-08-02 11:10 -0400
      Re: what may make the address of the member of the argument changed   when doing function call? Wojtek Lerch <wojtek_l@yahoo.ca> - 2011-08-02 16:55 -0400
        Re: what may make the address of the member of the argument changed   when doing function call? James Kuyper <jameskuyper@verizon.net> - 2011-08-03 10:18 -0400
    Re: what may make the address of the member of the argument changed when doing function call? "dSpam@arcor.de" <dSpam@arcor.de> - 2011-08-24 05:10 -0700

#744 — what may make the address of the member of the argument changed when doing function call?

Fromstefan <pengli.hust@gmail.com>
Date2011-08-02 07:10 -0700
Subjectwhat may make the address of the member of the argument changed when doing function call?
Message-ID<de86f4f5-4a2b-4021-bd07-b59308cdba86@y19g2000pre.googlegroups.com>
hi,everyone,
i have a problem, what may make the address of the member of the
argument changed when doing function call?

 here is the gdb status:


  2 Breakpoint 1, ngx_http_core_content_phase (r=0x9743058,
ph=0x976a804) at src/http/ngx_http_core_module.c:1353
  3 1353        if (r->content_handler) {
  4 (gdb) p r
  5 $25 = (ngx_http_request_t *) 0x9743058
  6 (gdb) p r->connection
  7 $26 = (ngx_connection_t *) 0x97e400c8
  8 (gdb) p r->connection->log
  9 $27 = (ngx_log_t *) 0x973cc78
 10 (gdb) p &r
 11 $28 = (ngx_http_request_t **) 0xbf927490
 12 (gdb) p &r->connection
 13 $29 = (ngx_connection_t **) 0x974305c
 14 (gdb) p &r->connection->log
 15 $30 = (ngx_log_t **) 0x97e400f4
 16 (gdb) n
 17 1354            r->write_event_handler =
ngx_http_request_empty_handler;
 18 (gdb) n
 19 1355            ngx_http_finalize_request(r, r-
>content_handler(r));
 20 (gdb) s
 21 ngx_http_drizzle_handler (r=0x9743058)
 22     at /home/lipeng/download/chaoslawful-drizzle-nginx-
module-2e813d1//src/ngx_http_drizzle_handler.c:29
 23 29      {
 24 (gdb) p r
 25 $31 = (ngx_http_request_t *) 0x9743058
 26 (gdb) p &r
 27 $32 = (ngx_http_request_t **) 0xbf92736c
 28 (gdb) p r->connection
 29 $33 = (ngx_connection_t *) 0x97e400c8
 30 (gdb) p &r->connection
 31 $34 = (ngx_connection_t **) 0x974305c
 32 (gdb) p r->connection->log
 33 $35 = (ngx_log_t *) 0x0
 34 (gdb) p &r->connection->log
 35 $36 = (ngx_log_t **) 0x97e400f0
 36

the address of [r->connection->log] changed when doing funciton call,

here is the code snip:
1345
ngx_int_t
1346 ngx_http_core_content_phase(ngx_http_request_t
*r,
1347     ngx_http_phase_handler_t
*ph)
1348
{
1349     size_t
root;
1350     ngx_int_t
rc;
1351     ngx_str_t
path;
1352
1353     if (r->content_handler)
{
1354         r->write_event_handler =
ngx_http_request_empty_handler;
1355         ngx_http_finalize_request(r, r-
>content_handler(r));
1356         return
NGX_OK;
1357     }
1358
1359     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log,
0,
1360                    "content phase: %ui", r->phase_handler);


and the content_handler is :
ngx_int_t
 28 ngx_http_drizzle_handler(ngx_http_request_t *r)
 29 {

}

[toc] | [next] | [standalone]


#745

FromJames Kuyper <jameskuyper@verizon.net>
Date2011-08-02 11:10 -0400
Message-ID<j1940v$983$1@dont-email.me>
In reply to#744
On 08/02/2011 10:10 AM, stefan wrote:
> hi,everyone,
> i have a problem, what may make the address of the member of the
> argument changed when doing function call?
> 
>  here is the gdb status:
> 
> 
>   2 Breakpoint 1, ngx_http_core_content_phase (r=0x9743058,
> ph=0x976a804) at src/http/ngx_http_core_module.c:1353
>   3 1353        if (r->content_handler) {
...
>   6 (gdb) p r->connection
>   7 $26 = (ngx_connection_t *) 0x97e400c8
...
>  14 (gdb) p &r->connection->log
>  15 $30 = (ngx_log_t **) 0x97e400f4
>  16 (gdb) n
>  17 1354            r->write_event_handler =
> ngx_http_request_empty_handler;
>  18 (gdb) n
>  19 1355            ngx_http_finalize_request(r, r-
>> content_handler(r));
...
>  28 (gdb) p r->connection
>  29 $33 = (ngx_connection_t *) 0x97e400c8
...
>  34 (gdb) p &r->connection->log
>  35 $36 = (ngx_log_t **) 0x97e400f0
> 
> the address of [r->connection->log] changed when doing funciton call,

I would expect that

	(char*)(&r->connection->log) - (char*)(r->connection)
		== offsetof(nqx_connection_t, log)

and I would not the validity of that identity would be something that
could be changed by calling a subroutine, not even if, as a result of
that call, some memory got corrupted. Technically, I can't be sure what
the value of that difference is, just by looking at the print outs of
the values of the pointers. However, in practice those values often have
a very obvious meaning. If so, then unless the debugger you're using is
seriously malfunctioning, it would appear my expectations are incorrect,
which suggests that I'm missing something, probably something very
simple that will cause me a lot of embarrassment when I figure out what
it is.

To help me figure out what I'm missing, could you print out the values
of the left and right operands of the above equality comparison, both
before and after executing line 1355?

> here is the code snip:

Code is a LOT easier to read without line numbers. Also, for some
reason, every single one of your lines seems to have wrapped, even the
short ones, which makes the code even harder to read. In any event, I
didn't identify any obvious problem by looking at your code. However, it
would help if, in the future, you printed it out without line numbers
and without unintentional wrapping. Use comments to tell us the
important line numbers, such as /* Line 1355. */.
-- 
James Kuyper

[toc] | [prev] | [next] | [standalone]


#746 — Re: what may make the address of the member of the argument changed when doing function call?

FromWojtek Lerch <wojtek_l@yahoo.ca>
Date2011-08-02 16:55 -0400
SubjectRe: what may make the address of the member of the argument changed when doing function call?
Message-ID<99r6hvF6qeU1@mid.individual.net>
In reply to#745
On 02/08/2011 11:10 AM, James Kuyper wrote:
>  However, it
> would help if, in the future, you printed it out without line numbers
> and without unintentional wrapping.

...  and preferably in a more appropriate newsgroup, right James?  ;-)

[toc] | [prev] | [next] | [standalone]


#748 — Re: what may make the address of the member of the argument changed when doing function call?

FromJames Kuyper <jameskuyper@verizon.net>
Date2011-08-03 10:18 -0400
SubjectRe: what may make the address of the member of the argument changed when doing function call?
Message-ID<j1blc0$qsq$1@dont-email.me>
In reply to#746
On 08/02/2011 04:55 PM, Wojtek Lerch wrote:
> On 02/08/2011 11:10 AM, James Kuyper wrote:
>>  However, it
>> would help if, in the future, you printed it out without line numbers
>> and without unintentional wrapping.
> 
> ...  and preferably in a more appropriate newsgroup, right James?  ;-)

I was so confused by the symptoms I didn't even notice that. Yes,
comp.lang.c or comp.lang.c.moderated would be more appropriate.
-- 
James Kuyper

[toc] | [prev] | [next] | [standalone]


#764

From"dSpam@arcor.de" <dSpam@arcor.de>
Date2011-08-24 05:10 -0700
Message-ID<6fc55d0c-03ab-40a4-b74c-b4a3a69686cf@x11g2000yqx.googlegroups.com>
In reply to#744
On 2 Aug., 16:10, stefan <pengli.h...@gmail.com> wrote:
> i have a problem, what may make the address of the member of the
> argument changed when doing function call?
>
>  here is the gdb status:
>
>   2 Breakpoint 1, ngx_http_core_content_phase (r=0x9743058,
> ph=0x976a804) at src/http/ngx_http_core_module.c:1353
>   ...
>   6 (gdb) p r->connection
>   7 $26 = (ngx_connection_t *) 0x97e400c8
>   ...
>  14 (gdb) p &r->connection->log
>  15 $30 = (ngx_log_t **) 0x97e400f4
>  ...
>  20 (gdb) s
>  21 ngx_http_drizzle_handler (r=0x9743058)
>  22     at /home/lipeng/download/chaoslawful-drizzle-nginx-
> module-2e813d1//src/ngx_http_drizzle_handler.c:29
>  ...
>  28 (gdb) p r->connection
>  29 $33 = (ngx_connection_t *) 0x97e400c8
>  ...
>  34 (gdb) p &r->connection->log
>  35 $36 = (ngx_log_t **) 0x97e400f0
>  36
>
> the address of [r->connection->log] changed when doing funciton call,
> ...

Apparently ngx_http_core_module.c and ngx_http_drizzle_handler.c were
translated with different definitions of ngx_connection_t or different
pack pragmas.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.std.c


csiph-web