From dmurdoch at pair.com  Fri Oct 24 01:02:03 2003
From: dmurdoch at pair.com (Duncan Murdoch)
Date: Fri Oct 24 01:01:00 2003
Subject: [Rd] linking to R.dll on Win32 - issues with recent MinGW?
In-Reply-To: <61B2C492-0553-11D8-BE10-000A957CEFBA@math.uni-augsburg.de>
References: <61B2C492-0553-11D8-BE10-000A957CEFBA@math.uni-augsburg.de>
Message-ID: <u0ngpvg8i24ga3ffde1cqhe1f1ml5o2op0@4ax.com>

On Thu, 23 Oct 2003 14:21:08 +0200, you wrote:

>I encountered several strange issues when linking to R.dll on Windows 
>and I wonder if anyone of the Windows savvy-folks here had seen some of 
>the issues before and have some explanation.

I can help with one of them, but not the main one.


>Now, I thought I'll use libR.a from the R sources instead of using the 
>final R.dll, because that's what libR.a is for, right? The first 
>obstacle was that libR.a doesn't export R_Home which I need to set in 
>my init routine, but fortunately there is "exported-vars" for that 
>case. But after finally compiling everything, Rserve crashes. It 
>doesn't even get as far as main. What I get is this:
>Warning: Invalid Address specified to RtlSizeHeap( 003F0000, 0146008 )
>and later a crash somewhere deep in libwsock32 (the trace is rather 
>weird) ... I guess the problem is the heap, not wsock itself. Any idea 
>what that could be?

This looks like what I see every time I run R under gdb.  The problem
is a bug/incompatibility in the MinGW run-time library.  R has its own
malloc, and some functions in the startup code expect the standard
MSVCRT malloc to be called, and it's not.  Within the debugger the
error is harmless, except for wasting some time.  I don't see the
later crash at a different location, but it sounds like a similar
symptom.

The workaround the MinGW folks told me was to rename the R malloc to
something else (e.g. by a define in Defn.h).  However, I got this
advice too close to the 1.8.0 release date to want to risk it.  I'll
try it for 1.9, not 1.8.1.

Duncan Murdoch


>
>All the above was tested with MinGW-3.1.
>Any ideas? Is that a MinGW bug or something I did? ;)
>
>Thanks.
>Simon
>
>---
>Simon Urbanek
>Department of computer oriented statistics and data analysis
>University of Augsburg
>Universit?tsstr. 14
>86135 Augsburg
>Germany
>
>Tel: +49-821-598-2236
>Fax: +49-821-598-2200
>
>Simon.Urbanek@Math.Uni-Augsburg.de
>http://simon.urbanek.info
>
>______________________________________________
>R-devel@stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-devel


[Rd] linking to R.dll on Win32 - issues with recent MinGW?
Duncan Murdoch