[m-dev.] Problem with loading object code

Tyson Dowd trd at cs.mu.OZ.AU
Tue Jan 9 12:48:02 AEDT 2001


On 08-Jan-2001, Ina Cheng <inch at students.cs.mu.oz.au> wrote:
> Hi,
> 
> I'm trying to load the object code in the webserver module, and basically what
> I did is just copy the `dl_test.m' sample program to the webserver but the
> following is resulted when I run the webserver. The code compiles without 
> any error.

The best way to persue this issue is to create a reproducible test case.
For example, a tar.gz file that contains the source code that produces
the error, plus instructions (or Mmakefiles) that will build it.

But... I just spent some time re-creating what I thought was your error,
and found that it seems to be caused by static linking. 

If you look at the Mmakefile int he dynamic_linking library you will see

# Use shared libraries, since they're needed for dynamic linking
MGNUCFLAGS = --pic-reg
MLFLAGS = --shared

# Link in the `-ldl' library (this may not be needed on some systems)
MLLIBS = -ldl

You need to add these lines to the Mmakefile in the server directory.
But make sure you don't shadow the definitions of other Mmake variables,
these flags need to be set in addition to other flags that are already
set.

I didn't think this would be necessary for dynamic linking in the
hlc.par.gc grade, but clearly it is.

Using this I have a version of the webserver that runs hello in
libhello.so every time you request a file from it.


> *** Mercury runtime: caught segmentation violation ***
> PC at signal: 1075880216 (4020a118)
> address involved: 0xbf800000
> This may have been caused by a stack overflow, due to unbounded recursion.
> exiting from signal handler
> Interrupted system call
> 
> (ps. I use telnet localhost 8080 to run the webserver)
> 
> The code is shown below:
> 
> 	% L = ./libfoo.so
> load_dynamic_library(L) -->
>         dl__open(L, lazy, local, MaybeHandle),
>         (
>                 { MaybeHandle = error(Msg) },
>                 print("dlopen failed: "), print(Msg), nl
>                 % XXX change print to stream__write
>         ;
>                         % Handle == handle(c_pointer)
>                 { MaybeHandle = ok(Handle) },
>                         % mercury_proc(is_pred_or_func, module_name, pred_name,
>                         %       arity, mode_num)
>                 { HelloProc = mercury_proc(predicate, unqualified("foo"),
>                                 "hello", 2, 0) } ,
>                 dl__mercury_sym(Handle, HelloProc, MaybeHello),
> 
>                 % { GetSPProc = mercury_proc(predicate, unqualified("foo"),
>                 %               "get_stockprice", 2, 0) } ,
>                 % dl__mercury_sym(Handle, GetSPProc, MaybeGetStockPrice),
>                 (
>                         { MaybeHello = error(Msg) },
>                         print("dlsym failed:" ), print(Msg), nl
>                 ;
>                         { MaybeHello = ok(HelloProc0) },
>                         { HelloPred = inst_cast(HelloProc0) },
>                         call(HelloPred)
>                 ),
>                 dl__close(Handle, Result),
>                 (
>                         { Result = error(CloseMsg) },
>                         print("dlclose failed: "), print(CloseMsg), nl
>                 ;
>                         { Result = ok }
>                 )
>         ).
> 
> The problem is with the line call(HelloPred).
> If I commented out that particular line, the webserver runs without error.
> Can anyone give me some advice on how to solve this error please? 
> 
> 
> Thanks
> Ina
> 
> --------------------------------------------------------------------------
> mercury-developers mailing list
> Post messages to:       mercury-developers at cs.mu.oz.au
> Administrative Queries: owner-mercury-developers at cs.mu.oz.au
> Subscriptions:          mercury-developers-request at cs.mu.oz.au
> --------------------------------------------------------------------------

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list