[GRASS-dev] r.los on windows question

Michael,

this is a problem with dirty memory allocation that never got fixed.
On some systems, like Linux, the memory manager is a bit more "relaxed"
and lets this pass. On Windows, it's more strict and kills
the application. The crashes appear a bit random which is typical for
memory allocation problems. The more allocations involved (read: the bigger
you set max_dist), the more probable it becomes that a sensitive memory
region gets corrupted and the program bails out.

If anyone wants to have a go at it: use Valgrind on Linux. It will tell
you exactly where the bad allocations happen. I actually had a go at this
years ago and it was quite easy to fix, but lost my notes in the meantime.

From memory: the problem can be fixed by delaying the release of memory
allocated at the start of each run through the main loop.

I have attached a file "delete3.c" from r.cva for which I fixed the same problem.
I believe this file is identical to the version that r.los uses except for the
changes I made. Look for the string "DELAYED". You should find my comments and
additions. Replicate them for r.los and you _should_ be OK (provided there were
no substantial changes to r.los since I wrote my fixed).

In main.c, the following has to be added towards the top of the file:

   if (G_parser (argc, argv))
     exit(EXIT_FAILURE);

   G_sleep_on_error (0);

   /* initialize delayed point deletion */
   DELAYED_DELETE = NULL;

And this toward the end:

   /* release that last tiny bit of memory ... */
   if ( DELAYED_DELETE != NULL ) {
     G_free ( DELAYED_DELETE );
   }

   return (0);
}

Unfortunately, I don't have the time to look into this myself at the moment.
Sorry for not being of more help. This is a long-standing, very annoying issue
that needs fixing urgently. It's embarassing to have such a basic tool fail in
this way.

Cheers,

Ben

----- Original Message -----
From: "Michael Barton" <Michael.Barton@asu.edu>
To: "developers grass" <grass-dev@lists.osgeo.org>
Sent: Thursday, February 26, 2009 9:20:10 PM GMT +00:00 GMT Britain, Ireland, Portugal
Subject: [GRASS-dev] r.los on windows question

Just ran into an issue in the OSGeo4W version of GRASS that I had
originally hit in 6.3 and subsequently forgotten about. I wonder if
anyone else has experienced this.

r.los with crash with a restart message in Windows XP if the max_dist
is too large. In the current case, even 9000 (9km) is too large.
Sometimes it works and sometimes it crashes.

Does anyone have any information about this?

Michael
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

------
Files attached to this email may be in ISO 26300 format (OASIS Open Document Format). If you have difficulty opening them, please visit http://iso26300.info for more information.

(attachments)

delete3.c (3.51 KB)

Benjamin wrote:

this is a problem with dirty memory allocation that never
got fixed.

....

If anyone wants to have a go at it: use Valgrind on Linux.
It will tell you exactly where the bad allocations happen.

Markus has done that already; posted to the bug tracker:
  http://trac.osgeo.org/grass/ticket/111

From memory: the problem can be fixed by delaying the release of memory
allocated at the start of each run through the main loop.

also if anyone is interested r.viewshed from wiki addons only needs some
cleanup and small bug fixes to have a LOS app which scales a lot better.

Hamish

On Sun, Mar 1, 2009 at 3:22 AM, Hamish <hamish_b@yahoo.com> wrote:
...

also if anyone is interested r.viewshed from wiki addons only needs some
cleanup and small bug fixes to have a LOS app which scales a lot better.

Given the extreme speed improvement of r.viewshed from addons
I consider fixing r.los a waste of time.
BUT: there is a precision fix needed in r.viewshed, see:
http://trac.osgeo.org/grass/ticket/390

Markus