?

Log in

No account? Create an account

[icon] Linux puzzler - Patti
View:Recent Entries.
View:Archive.
View:Friends.
View:Profile.
View:Website (pattib.org).

Security:
Subject:Linux puzzler
Time:05:10 pm
You have two ssh windows open to the same system. It's your test system, and you tend to stay logged in for days or weeks at a time, since you're using it a lot. In each of the windows, you type the following commands and get the following output:

% hostname
foo.bar.com
% pwd
/foo/bar/bat
% cat bam/file1
result1

% hostname
foo.bar.com
% pwd
/foo/bar/bat
% cat bam/file1
result2



To recap: you're in the exact same directory on the exact same computer, and when you try to look at the exact same file you get two different results.

Anyone want to guess how that happened? Until I figured it out, I thought I was losing my mind!
comments: Leave a comment Previous Entry Share Next Entry

songmonk
Link:(Link)
Time:2008-05-06 12:48 am (UTC)
I feel like I've experienced this before, but given that I can't remember or think of a cause, I'm not sure whether I really have or not.
(Reply) (Thread)


ts4z
Link:(Link)
Time:2008-05-06 12:57 am (UTC)
Directory moved and renamed?

In a chroot environment?

See also my similar gdb experience.
(Reply) (Thread)


evwhore
Link:(Link)
Time:2008-05-06 01:02 am (UTC)
Directory renamed/moved was the first thing that came to mind. /bin/pwd vs pwd is your friend.
(Reply) (Parent) (Thread)


burr86
Link:(Link)
Time:2008-05-06 02:08 am (UTC)
#1 and #2 were the first things that came to mind, in that order.
(Reply) (Parent) (Thread)

(Deleted comment)

whipartist
Link:(Link)
Time:2008-05-06 04:56 am (UTC)
It's obviously not a charset difference-- the contents of the files are URLs.
(Reply) (Parent) (Thread)

(Deleted comment)

freelikebeer
Subject:Pulling from out of the bag...
Link:(Link)
Time:2008-05-06 01:21 pm (UTC)
file1 is a symbolic link set when the shell starts up? Symbolic link goes to some [different] cached version of the actual file1 [and file1 is something like the-last-twenty-GETs-served].
(Reply) (Parent) (Thread)


tigerknight
Link:(Link)
Time:2008-05-06 04:29 am (UTC)
I'd be curious to see the genuine differing output rather than the generalized/anonymized 'result1/2' since that might give a clue. Open file handles could possibly explain the issue if you had done some manipulation of the file at some point on one shell but not the other, but other than that I am clueless and would support the possibility of the locale/character encoding difference being the most likely difference between the two causing this.
(Reply) (Thread)


whipartist
Link:(Link)
Time:2008-05-06 04:57 am (UTC)
The contents of the files are (among other things) URLs. It's clear that you're getting two different copies of the file, rather than a different interpretation of the same file contents.

If you'd like, think of them as:

http://foo/bar/result1
http://foo/bar/result2
(Reply) (Parent) (Thread)


playfulswitch
Link:(Link)
Time:2008-05-06 05:32 am (UTC)
The file actually changed (obvious, but not interesting or worth a post, so discarded)

Hmmm, the 'you tend to stay logged in for days, weeks...' bit sounds significant...

Environement variables setup differently in the two sessions

Different NFS mounting in the two sessions

Earlier in session 1:
cd ..
mv bat batOld
mkdir bat
cd bat



(Reply) (Thread)


timprov
Link:(Link)
Time:2008-05-06 12:22 pm (UTC)
If you use cat ./bam/file1 does the same thing happen? I seem to remember that annoying me once.
(Reply) (Thread)


soakland
Link:(Link)
Time:2008-05-06 11:01 pm (UTC)
Don't think it could be actual file system inconsistency.

On the other hand, we know nothing about environment in the two shells, and bam (or for that matter cat) could be aliased to different things in each window.
(Reply) (Thread)


xb95
Link:(Link)
Time:2008-05-07 12:58 am (UTC)
I haven't read the comments yet.

This can happen because the directory gets renamed or moved, so you end up in the "same" directory, but it's technically two different inodes.

I'd typically expect this in /tmp, /var, or something that goes away often like that. (Maybe your app is doing something wonky...)
(Reply) (Thread)

[icon] Linux puzzler - Patti
View:Recent Entries.
View:Archive.
View:Friends.
View:Profile.
View:Website (pattib.org).