This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Path conversion bug with check_case:strict

On Tue, 7 Sep 2004, Corinna Vinschen wrote:

> On Sep  7 12:32, Igor Pechtchanski wrote:
> > Hi,
> >
> > I've been tracking down some weird behavior on my machine.  Basically,
> > when a windows program is invoked from a Cygwin one, the PATH got
> > truncated at the first "/cygdrive/*" entry.  To reproduce, add
> > "check_case:strict" to $CYGWIN, change one of the default Windows PATH
> > entries to have incorrect case, run "cmd" from bash, and observe that
> > "echo %PATH%" prints a truncated PATH.
> >
> > I finally managed to find the culprit: path_conv::check will break off
> > converting the path if it contains a directory with the wrong case and
> > check_case is set to strict.  The call sequence, AFAICS, is as follows:
> > 	spawn_guts()
> > 	  build_env()
> > 	    getwinenv()
> > 	      winenv::add_cache()
> > 		cygwin_posix_to_win32_path_list()
> > 		  conv_path_list()
> > 		    cygwin_conv_to_win32_path()
> > 		      path_conv::path_conv()
> > 			path_conv::check()
> > (I have a full gdb stack trace if needed).
> >
> > I'm not quite sure what the right fix for this would be, as
> > path_conv::check is a pretty generic method called all over the place, and
> > this particular call sequence has nothing special to identify it.  My
> > guess at the fix would be to save the value of pcheck_case in build_env,
> > set it to PCHECK_RELAXED, do the conversion, and then restore it.  What do
> > people think?  If this is an acceptable solution, I'll start the process
> > of sending in a patch.
> What about adding a value to enum pathconv_arg, say PC_IGNORE_CASE or so,
> which could be added to calls to path_conf?  Temporary changing the value
> of pcheck_case doesn't sound exactly thread safe.

Umm, I'm not sure this'll work.  The problem is that the check_case
setting should be ignored (i.e., set to PCHECK_RELAXED) only when
converting paths that originated as Win32 paths back to Win32 format
(e.g., when spawning a Windows process).  The call to the path_conv
constructor is by then buried in the chain of other generic calls
(cygwin_posix_to_win32_path_list() -> conv_path_list() ->
cygwin_conv_to_win32_path()), some of them via function pointers.  We may
be able to use a different function at one of the levels, but that would
probably break encapsulation and be pretty ugly...

But your point is valid -- setting pcheck_case isn't thread-safe.  I'll
think of some way of fixing this.

> Sigh, check_case is just another invention I'd rather like to get rid of.
> Like ntea or textmode...

Well, check_case actually turns out to be very useful (at least to me),
particularly when a tarball or a CVS repository contains two files that
differ only in case -- I'd rather have an error in that case rather than
have the file/directory silently overwritten.  FWIW, I use it constantly
(that's how I spotted this problem).
      |\      _,,,---,,_
ZZZzz /,`.-'`'    -.  ;-;;,_
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing."  -- Dr. Jubal Harshaw

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]