[Mono-list] strange mono initialization problem

John Sohn jsohn@columbus.rr.com
23 Aug 2002 01:52:45 -0400

Actually these are the functions in WineLib I am aware of that conflict
with the Mono JIT library (it is possible more overlapped functions


These functions in WineLib are getting called from the Mono JIT code
instead of the correct functions in libmono (mono/io-layer/threads.c).

The functions I mentioned below (Rtl...) are called from the Tls...
functions in the WineLib source. I was in the wrong spot in the debugger
when I researched the original mail. I apologize if this caused any


On Fri, 2002-08-23 at 00:37, John Sohn wrote:
> Thank you for taking a look at this problem. I appreciate your
> assistance.
> > 
> > Please, can you elaborate on what kind of conflicts?
> > Statically linking the mono engine is not a good idea, generally: the
> > only app that may do it is mono itself (for speed reasons: linking it
> > dynamically gets us a 5-10% slowdown).
> > 
> I would also prefer to use the shared library however there are
> functions in the Mono JIT project that conflict with actual Win32
> functions. I used the debugger to step through the dynamically linked
> libmono.so code and it was calling WINE's RtlEnterCriticalSection (and
> other Rtl... functions) instead of Mono's. If the function names were
> not exactly the same I believe I could dynamically link the mono
> runtime. If I take the same project/makefile and link to libmono.a
> instead of libmono.so the project behaves properly. Using the static
> library ensures the correct functions are getting called. Perhaps
> there's a gcc/link setting I'm not aware of that would fix this problem.
> > Something may have changed in the build setup, but nothing in the code
> > is related to this issue. Hans Boehm says it may actually be a bug in
> > the dynamic linker and he added a workaround in gc 6.1.
> > 
> I had no problems running your test application you sent. As a test I
> created a created new, very simple GC/WineLib application:
> #include <gc/gc.h>
> #include <windows.h>
> #include <stdio.h>
> int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
>                     LPSTR lpszCmdLine, int nCmdShow)
> {
>         void* test = NULL;
>         printf("start\n");
>         test = GC_malloc(1);
>         printf("end\n");
> }
> It segfaults while calling GC_malloc. As a result I believe you are 
> correct about this being a problem with the garbage collection library.
> I took a closer look at the other point in the Mono code where the
> application crashed and it was also caused by a call to GC_malloc. I
> have tried to use different settings while compiling the GC library and
> the WineLib test application and I have also tried setting the various
> GC environment variables while running the application. So far I have
> been unable to resolve this issue.
> In summary, I am unable to use the Mono embedding API in a WineLib
> application unless I statically link the Mono JIT engine with garbage
> collection disabled. I would prefer to use the standard shared library
> with garbage collection enabled. I appreciate any suggestions you may
> have.
> Thanks,
> John
> _______________________________________________
> Mono-list maillist  -  Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list