[GRASS-dev] Re: [GRASS GIS] #718: r.li forgets mask/illegal filename

GRASS GIS trac at osgeo.org
Mon Aug 17 03:11:18 EDT 2009

#718: r.li forgets mask/illegal filename
  Reporter:  kyngchaos  |       Owner:  grass-dev at lists.osgeo.org
      Type:  defect     |      Status:  new                      
  Priority:  normal     |   Milestone:  6.4.0                    
 Component:  Raster     |     Version:  6.4.0 RCs                
Resolution:             |    Keywords:  r.li, smp                
  Platform:  All        |         Cpu:  All                      
Changes (by hamish):

  * keywords:  r.li => r.li, smp


 FWIW I'd note that I got this error on a 32bit Pentium4 running
 *** glibc detected *** malloc(): memory corruption: 0x09166940 ***
 D0/0: daemon while loop: toReceive.type=-1208818294
 Illegal filename. Character <   > not allowed.


 ok, with the help of Nathan's backtrace in today's grass-user post I
 tracked it down to this:

 source:grass/trunk/raster/r.li/r.li.daemon/daemon.c at 38766#L397

         } while ((token = strtok(NULL, " ")) != NULL &&
                strcmp(token, "SAMPLEAREA") == 0);

 note the glibc man page for strtok() says:
        Avoid using these functions.  If you do use them, note that:

               These functions modify their first argument.

               These functions cannot be used on constant strings.

               The identity of the delimiting character is lost.

               The strtok() function uses a static buffer while  parsing,
               so it's not thread safe. Use strtok_r() if this matters to

        The strtok() and strtok_r() functions return  a  pointer  to  the
        next token, or NULL if there are no more tokens.

               SVr4, POSIX.1-2001, 4.3BSD, C89.


 i.e. strtok() is '''not thread safe''' and it is being used in a thread.
 The result is breakage. And strtok_r() is not as portable as we require.

 in light of that, could our G_tokenize() help? AFAICS this is just for
 simple plain text string parsing stuff, so no huge drama to work around

 Maybe the landclass96_conf above doesn't break for me because it only has
 1 line with a space in it?


Ticket URL: <https://trac.osgeo.org/grass/ticket/718#comment:16>
GRASS GIS <http://grass.osgeo.org>

More information about the grass-dev mailing list