Opened 18 years ago

Closed 18 years ago

#1758 closed defect (fixed)

make test fails with C# MONO on linux

Reported by: szekerest Owned by: szekerest
Priority: high Milestone:
Component: MapScript-SWIG Version: 4.8
Severity: normal Keywords:
Cc:

Description

I have recently added a simple make test functionality for the linux csharp
build. The test simply runs the sample applications compiled along with
mapscript like java does.

the drawmap sample fails with the following error:

Unhandled Exception: System.ApplicationException: loadMapInternal(): General
error message. Given map extent <-0,000000, 50,000000, 0,000000, 51,000000> is
invalid. Check that it is in the form: minx, miny, maxx, maxy
in <0x0003d> mapObj:.ctor (System.String filename)
in <0x00056> DrawMap:Main (System.String[] args)
make: *** [test] Error 1

The problem occurs when parsing the EXTENT parameter in the map file and the
atof() function truncates the float values to integers.
I have modified mapfile.c to print the EXTENT values parsed:

mono ./drawmap.exe ../../tests/test.map test_csharp.png
msyytext= -0.5 msyynumber= -0,000000, atof(msyytext)= -0,000000 
strtod(msyytext)= -0,000000
msyytext= 50.977222 msyynumber= 50,000000, atof(msyytext)= 50,000000 
strtod(msyytext)= 50,000000
msyytext= 0.5 msyynumber= 0,000000, atof(msyytext)= 0,000000  strtod(msyytext)=
0,000000
msyytext= 51.977222 msyynumber= 51,000000, atof(msyytext)= 51,000000 
strtod(msyytext)= 51,000000

I have implemented the same functionality inside mapscript_wrap.c and when
compiling without -shared and running the application directly works well.

The compilation method is almost the same like java but it does not suffer with
this issue.

Tamas Szekeres

Change History (5)

comment:1 by fwarmerdam, 18 years ago

Tamas, 

It looks like a non-default locale is being used in parsing the values in
the file.  I see a "," is being used in preference to a "." for the decimal
point when re-encoding the values in the error message. 

Generally speaking it is desirable to run MapServer in the C numeric locale. 
I suspect the C# runtime is using a different locale and it is affecting the
C runtime library or something like that.  

One crude approach to this is to call the following when initializing mapserver:

  setlocale( LC_NUMERIC, "C" );

I would add that some supporting libraries such as GDAL/OGR are also quite
sensitive to locale settings. 

comment:2 by szekerest, 18 years ago

 
Yes it was a local specific issue, I have added some additional prints to the
program:

current locale (LC_NUMERIC)=  hu_HU.UTF-8
locale.decimal_point=,
atof(51.447)=51,000000  atof(51,447)=51,447000

So the question is: if the parser expects dots as the decimal separator for
floats it should set the default locale previously or use locale independent
conversion, like atof_l.

Tamas


comment:3 by unicoletti, 18 years ago

Tamas,
if you change the language settings in your shell (by exporting the LANG anc
LC_* variables) does the issue go away?

comment:4 by szekerest, 18 years ago

>if you change the language settings in your shell (by exporting the LANG anc
>LC_* variables) does the issue go away?

Yeah, applying "export LC_NUMERIC=C" causes make test for C# to work. It
demonstartes that the mono runtime takes over the locale setting of the
environment  
causing this bug to come up.

Tamas

comment:5 by szekerest, 18 years ago

Resolution: fixed
Status: newclosed
Setting LC_ALL=C for mono in the make test
Committed to the CVS head. 


Note: See TracTickets for help on using tickets.