DVE 5.1.3 possible bug: Expression has different result when using debugger

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

DVE 5.1.3 possible bug: Expression has different result when using debugger

Bernhard Kohlhaas-2
Hello,

I have the following odd behavior with DVE 5.1.3
on WinXP Professional SP01:

When I am evaluating the expression
        test := File relativePathOf: 'C:\test\' to: 'C:'.
it evaluates to: 'test\'

When I am using the debugger on the expression (marking it
and hitting F11), and then immediately hit "Go" (F5),
the variable "test" has afterwards the value '..\test\'

This difference in the result strikes me as rather odd.
Comments anyone?

Bernhard


Reply | Threaded
Open this post in threaded view
|

Re: DVE 5.1.3 possible bug: Expression has different result when using debugger

Ian Bartholomew-18
Bernhard,

> This difference in the result strikes me as rather odd.
> Comments anyone?

That's really weird isn't it.  I've no idea why it happens but have
found it can get even weirder :-)

You can reduce it to a set of 3 expressions ...

relPath := String new: File maxPath.
ShlwapiLibrary default
    pathRelativePathTo: relPath
    pszFrom: 'c:'
    dwAttrFrom: 0
    pszTo: 'c:\test\'
    dwAttrTo: 0.
relPath inspect

Using F11/F5 this sometimes works as expected (answers .\test\) and
sometimes fails (answers ..\test\).  It also seems to depend on which
bits you evaluate under the debugger and which you evaluate normally -
but it doesn't do it consistently.  Another oddity...

1 to: 100 do: [:index |
    test := File relativePathOf: 'C:\test\' to: 'C:'.
    test = 'test\' ifFalse: [self halt]]

copy that into a workspace and then exit Dolphin, saving the current
image.
Start Dolphin, highlight the expression and then hit F11/F5.  This
works.  Highlight and hit F11/F5 again. This fails!! Keep trying and
every so often it works again.

Two observations.
- If you use 'c:\' as the from path then it always seems to work.
Perhaps 'c:' is not a valid path (sometimes :-) )
- MSDN shows the two dwAttr parameters as being set to 16
(FILE_ATTRIBUTE_DIRECTORY) if you are comparing paths.  If that bit of
the parameter is not set then it assumes you are comparing files.  In
practice it doesn't seem to make any difference but is worth mentioning.

--
Ian


Reply | Threaded
Open this post in threaded view
|

Re: DVE 5.1.3 possible bug: Expression has different result when using debugger

Chris Uppal-3
Ian Bartholomew wrote:

> Perhaps 'c:' is not a valid path (sometimes :-) )

It isn't ever a valid path is it ?  I mean, 'C:' should mean the "current
directory" on the C drive, not the root of the C: filesystem.

    -- chris

(BTW, it's nice to see you back among us Ian)


Reply | Threaded
Open this post in threaded view
|

Re: DVE 5.1.3 possible bug: Expression has different result when using debugger

Ian Bartholomew-18
Chris,

> It isn't ever a valid path is it ?

I quite agree (although I don't really know if it is spelled out this
way in any OS documentation?)

'c:' is a drive designator
'c:\' is the path for the root folder on the c drive

The trouble is that because so many applications seem to accept 'c:' or
'c:\' as the path for the root folder anything that doesn't allow it can
cause confusion.

> (BTW, it's nice to see you back among us Ian)

Thanks.  I've always been around but as I haven't been using Dolphin
much I haven't had a lot to contribute:-)

--
Ian


Reply | Threaded
Open this post in threaded view
|

Re: DVE 5.1.3 possible bug: Expression has different result when using debugger

Stefan Schmiedl
In reply to this post by Bernhard Kohlhaas-2
On Sat, 06 Dec 2003 18:28:57 -0800,
Bernhard Kohlhaas <[hidden email]> wrote:

>
> When I am evaluating the expression
> test := File relativePathOf: 'C:\test\' to: 'C:'.
> it evaluates to: 'test\'
>
> When I am using the debugger on the expression (marking it
> and hitting F11), and then immediately hit "Go" (F5),
> the variable "test" has afterwards the value '..\test\'
>
> This difference in the result strikes me as rather odd.
> Comments anyone?

Strange, indeed.

Try it with a virgin image. There is no difference between
the results on my machine.

s.
--
Stefan Schmiedl
+-------------------------------+----------------------------------------+
|Approximity GmbH               | EDV-Beratung Schmiedl                  |
|http://www.approximity.com     | Am Bräuweiher 4, 93499 Zandt, Germany  |
|mailto:[hidden email]  | Tel. (09944) 3068-98, Fax -97          |
+-------------------------------+----------------------------------------+


Reply | Threaded
Open this post in threaded view
|

Re: DVE 5.1.3 possible bug: Expression has different result when using debugger

Bernhard Kohlhaas-2
In reply to this post by Ian Bartholomew-18
Ian Bartholomew wrote:

> Chris,
>
>
>>It isn't ever a valid path is it ?
>
>
> I quite agree (although I don't really know if it is spelled out this
> way in any OS documentation?)
>
> 'c:' is a drive designator
> 'c:\' is the path for the root folder on the c drive
>
> The trouble is that because so many applications seem to accept 'c:' or
> 'c:\' as the path for the root folder anything that doesn't allow it can
> cause confusion.

I agree with you, but I actually meant the drive designator. So what I
was hoping to see is
   File relativePathOf: 'C:\test\' to: 'C:'
to evaluate to
   '\test\'
(with the root path included).

But perhaps that's a different discussion altogether, that is what the
method SHOULD return. For now I am just surprised that it (or rather the
underlying DLL call) returns two different results, depending on the
circumstances.

Bernhard


Reply | Threaded
Open this post in threaded view
|

Re: DVE 5.1.3 possible bug: Expression has different result when using debugger

Harry Chomsky
In reply to this post by Chris Uppal-3
"Chris Uppal" <[hidden email]> wrote in message
news:3fd31f6a$0$13476$[hidden email]...
> Ian Bartholomew wrote:
>
> > Perhaps 'c:' is not a valid path (sometimes :-) )
>
> It isn't ever a valid path is it ?  I mean, 'C:' should mean the "current
> directory" on the C drive, not the root of the C: filesystem.

So then it *is* a valid path, right?  It's a relative path, not an absolute
path, but valid nonetheless.  The expression "File relativePathOf:
'C:\test\' to: 'C:'" should have a predictable result that just depends on
which directory is current on C: at the time it's evaluated.  It should be
just like "File relativePathOf: 'C:\test\' to: '.'", assuming C: is the
current drive.

Is it possible that something is causing the current directory on C: to
shift around as you're running these tests?  (I don't have a Dolphin
installation handy right now so I can't test it myself...)


Reply | Threaded
Open this post in threaded view
|

Re: DVE 5.1.3 possible bug: Expression has different result when using debugger

Chris Uppal-3
Harry Chomsky wrote:

> > It isn't ever a valid path is it ?  I mean, 'C:' should mean the
> > "current directory" on the C drive, not the root of the C: filesystem.
>
> So then it *is* a valid path, right?  It's a relative path, not an
> absolute path, but valid nonetheless.

Yes, true.  And in fact, from MSDN:

"
This function takes a pair of paths and generates a relative path from one to
the other. The paths do not have to be fully-qualified, but they must have a
common prefix, or the function will fail and return FALSE.
"


> Is it possible that something is causing the current directory on C: to
> shift around as you're running these tests?

It looks as if there may be two issues here:

1) the result comes out different under the debugger (though that may
just reflect some underlying instability in (2)).

2) the swlapi function seems to be broken.  E.g:

File fullPathOf: 'C:'.
    --> 'C:\Program Files\Dolphin Smalltalk 5.1'
This is correct and remains fixed I think.

File
    relativePathOf: 'C:\Program Files\Dolphin Smalltalk 5.1\Dolphin.exe'
    to: 'C:'.
    --> 'Program Files\Dolphin Smalltalk 5.1\Dolphin.exe'
Note that the answer is *wrong*, it should be just 'Dolphin.exe' or
'C:\.....\Dolphin.exe' or something in-between.  Dolphin.exe does exist in that
directory, btw, in case it matters.

Now, done under the debugger:
File
    relativePathOf: 'C:\Program Files\Dolphin Smalltalk 5.1\Dolphin.exe'
    to: 'C:'
    -->  '..\Program Files\Dolphin Smalltalk 5.1\Dolphin.exe'
The answer is different but still wrong :-(

BTW, this is all done with a clean D5.1.2 on WinXP Pro.  I tried briefly with
5.1.0 over W2K, and the answer seems to be stable on that OS, but is
nevertheless still wrong...

Hey ho....

    -- chris