Boost logo

Boost-Build :

Subject: Re: [Boost-build] build engine crashes when GLOBing paths with forward slashes on windows
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2012-02-23 10:17:27


AMDG

On 02/23/2012 03:21 AM, Marc Dürner wrote:
> However the code still looks a bit strange. there is a tricky
> recursion. Please review if the following can still happen:
>

This can't happen because ShortPathToLongPath
strips off the last path element before calling
path_write_key. The result is that given the
path: "C:\Users\Steven\Documents"

We end up calling

ShortPathToLongPath("C:\Users\Steven\Documents")
 -> path_write_key("C:\Users\Steven")
   -> ShortPathToLongPath("C:\Users\Steven")
     -> path_write_key("C:\Users")
       -> ShortPathToLongPath("C:\Users")
         -> path_write_key("C:\")
           -> ShortPathToLongPath("C:\") - base case

> static void path_write_key( char * path_, string * out )
> {
> struct path_key_entry e, *result = &e;
> OBJECT * path = object_new( path_ );
>
> /* This is only called by path_as_key, which initializes the cache. */
> assert( path_key_cache );
>
> result->path = path;
> 1: if ( hashenter( path_key_cache, (HASHDATA * *)&result ) )
> {
> /* path_ is already normalized. */
> 2: ShortPathToLongPath( path_, out );
> 3: result->key = object_new( out->value );
> }
> else
> {
> object_free( path );
> 4: string_append( out, object_str( result->key ) );
> }
> }
>
> Lets assume we enter path_write_key() with a path that is not in the
> cache yet. The function hashenter() will return true if a new element
> was added [1]. Eventually we reach [2] and enter
> ShortPathToLongPath(), which calls path_write_key() again, in my case
> protentially with the same path.The function hashenter will return
> false in the following invokation of path_write_key(), because the
> element is already in the cache. But it wasn't initialized yet,
> because that happens at [3]. So we access uninitialized data in [4].
>

In Christ,
Steven Watanabe


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk