[mercury-users] Strange segfault (Mercury, C, C++, sockets, libraries...)

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Mar 15 03:36:34 AEDT 2003


On 14-Mar-2003, Ondrej Bojar <oboj7042 at ss1000.ms.mff.cuni.cz> wrote:
> The only thing that surprises me is in main:
> ... the gdb reports this order of calls:
...
> (gdb) 71            { lookup_string_option(Opts, host, Host) },
> (gdb) 72            { lookup_int_option(Opts, port, Port) },
> (gdb) 73            db_mint__init(DB),
> (gdb) 72            { lookup_int_option(Opts, port, Port) },
> (gdb) 73            db_mint__init(DB),
> (gdb) db_mint__init_3_p_0 (db_mint__Out_4=0xbffff460) at db_mint.m:73
> 
> ...i.e. there and back again. However, the initialization in C itself is
> called only once.

Thanks for mentioning that -- I had a look at this, and in this case it
seems to be due to a minor bug in the way we output #line directives in
the generated C code, which I will fix.

[In case you are curious, here's the explanation.  Some lines of the
generated C code do not correspond to any line of the Mercury source
code (well, actually they do, but it's a fairly tenuous connection,
and the Mercury compiler does not keep track of it).  For these lines,
we do not have any source line information, and so we were not generating
any #line directive.  But this is wrong -- it causes the C compiler
to assume that such lines come from the next line in the source file
after wherever the previous line in the C file came from.  To avoid this,
we need to output a #line directive to reset the line number back to
the corresponding line in the generated C file.]

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list