Closed Bug 56998 Opened 25 years ago Closed 24 years ago

nsLocalFile::Exists() is wrong

Categories

(Core :: XPCOM, defect, P3)

PowerPC
Mac System 8.6
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: ccarlen, Assigned: ccarlen)

References

Details

(Whiteboard: [rtm-] r=sfraser, sr=scc, Checked in on trunk)

Attachments

(1 file)

See http://lxr.mozilla.org/seamonkey/source/xpcom/io/nsLocalFileMac.cpp#1849. If ResolveAndStat returns some error other than NS_ERROR_FILE_NOT_FOUND, it is ignored. If the error caused ResolveAndStat to not set mTargetSpec, it will (most likely) do the existence test on a zeroed out spec which will always return noErr. Basically, this method can return TRUE for completely bad files which don't exist.
The patch above fixes this. This really needs to go in. I discovered this while reviewing bug 56041. Not being able to reliably tell whether files exist threatens the effectiveness of the patch for 56041.
You're using FSMakeFSSpec() as a surrogate for a file existence test; ideally, you should use PBGetCatInfoSync() for this. However FSMakeFSSpec() probably just calls PBGetCatInfoSync() under the hood. Do you care if this is a file or folder? Your code won't tell you, but using PBGetCatInfoSync() and testing the bits in pBlock.hFileInfo.ioFlAttrib will.
Status: NEW → ASSIGNED
Only if there was a difference in speed. I could use the microsecond timer and see if there was any difference. I doubt but, while testing, I noticed that this got called LOTS of times. No, it doesn't matter if it's a file or folder.
ok, r=sfraser
Just for curiosity's sake (and because it was getting called so much), I did measure it and found that both FSMakeFSSpec and PBGetCatInfo both average about 35 microseconds. Thanks for the quick r=.
Blocks: 56041
Nominating for rtm. This needs to go in because because it blocks 56041 which is (hopefully) going onto the branch. This fix is very small. I would say it is extremely low risk.
Keywords: rtm
Marking [rtm need info] since you are working on a patch. The patch looks approvable if you can get your sr=. When you have sr=, please change the whiteboard to [rtm+].
Whiteboard: [rtm need info]
Whiteboard: [rtm need info] → [rtm need info] r=sfraser, NEED SR=
This serious bug has been sitting here, waiting for a sr= for the last week now. Adding waterson to cc to see if he can help us get a sr.
This has been checked into the trunk on 10/19 with, by now we can say, no ill effect.
Whiteboard: [rtm need info] r=sfraser, NEED SR= → [rtm need info] r=sfraser, NEED SR=, Checked in on trunk
This has now been sitting here for *2* weeks, waiting for a sr.
I'm curious how this got checked into the trunk with out a super reviewer? Anyone?
Because Simon gave r= and he is a super-reviewer.
1. It's claimed that this blocks 56041, but that bug is already checked into the branch. Was that badness, or is this not a blocker for that bug? 2. What existing user-visible symptom exists for this bug? (I am fully aware of the potential you're describing, but would still like to know what errors a real user would see with today's build.) Has an email been sent to the reviewers alias asking for a super review? Let's get this resolved ASAP!
The patch for 56041 evolved several times. I think the final patch for 56041 was not dependent on this. Either way, this patch is very simple, and the previous code was clearly wrong. Normally, sfraser is the one to ask for Mac-specific super-review. I'll try scc.
this looks ok to me and I'm tempted to give it an sr=mscott but to be honest I don't consider myself a mac expert to properly measure the behavior of ::FSMakeFSSpec. scc, can you take a quick look at this patch and give the final sr=?
looks good to me. sr=scc. Changing whiteboard accordingly.
Whiteboard: [rtm need info] r=sfraser, NEED SR=, Checked in on trunk → [rtm+] r=sfraser, sr=scc, Checked in on trunk
OK, 56041 is out of the picture. What user-visible symptoms can be seen if this bug is not fixed?
I don't know of any user-visible symptoms. Being told that a file exists when it doesn't - sounds like a user-visible symptom waiting to happen though. PDT's call though. If it can't be checked in to the branch, I would like to mark it fixed (it is on trunk) and forget it. The time spent on this page is now about 10x what it took to fix the bug.
rtm-, without such symptoms, can't take the risk now.
Whiteboard: [rtm+] r=sfraser, sr=scc, Checked in on trunk → [rtm-] r=sfraser, sr=scc, Checked in on trunk
Since it's checked into trunk, at this point, isn't it fixed.
Checked into trunk long ago. It was left open back then waiting to go into 6.0 branch. Since that's long gone, this is fixed.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: