Closed Bug 37761 Opened 24 years ago Closed 24 years ago

assert in nslocalstore.cpp

Categories

(NSPR :: NSPR, defect, P3)

x86
OS/2
defect

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: snizinsk, Assigned: wtc)

Details

1) click on tinderbox, then search results, then What's Related (all on the 
sidebar)
2) close the browser
3) restart the browser

Browser takes an assert in nsLocalStore.cpp.  This is because some junk
characters exist at the bottom of users50\mozProfile\localstore.rdf (or wherever
your user directory is located).  What is happening is that localstore.rdf is
writing out, but it isn't writing into a fresh file but rather into the file
that already exists.  So if a smaller output is written into localstore.rdf that
holds larger output, the tail end of the larger output still exists.  Next time
it tries to compeletly parse localstore.rdf, the assertion.

Index: os2io.c
===================================================================
RCS file: /cvsroot/mozilla/nsprpub/pr/src/md/os2/os2io.c,v
retrieving revision 3.5.18.1
diff -u -r3.5.18.1 os2io.c
--- os2io.c	2000/04/04 00:12:42	3.5.18.1
+++ os2io.c	2000/05/01 19:55:41
@@ -24,10 +24,11 @@
  * identified per MPL Section 3.3
  *
  * Date             Modified by     Description of modification
- * 03/23/2000       IBM Corp.       Changed write() to DosWrite(). EMX i/o
- *                                  calls cannot be intermixed with DosXXX
- *                                  calls since EMX remaps file/socket
- *                                  handles.
+ * 03/23/2000       IBM Corp.      Changed write() to DosWrite(). EMX i/o calls 
cannot be intermixed 
+ *                                         with DosXXX calls since EMX remaps 
file/socket handles.
+ * 04/27/2000       IBM Corp.      Changed open file to be more like NT and
+ *                                 better handle PR_TRUNCATE | PR_CREATE_FILE
+ *                                 and also fixed _PR_MD_SET_FD_INHERITABLE
  */
 
 /* OS2 IO module
@@ -121,7 +122,7 @@
 {
     HFILE file;
     PRInt32 access = OPEN_SHARE_DENYNONE;
-    PRInt32 flags = OPEN_ACTION_OPEN_IF_EXISTS;
+    PRInt32 flags = 0L;
     PRInt32 rc;
     PRUword actionTaken;
 
@@ -129,17 +130,32 @@
     LONG ReqCount = 1;
     ULONG fattr;
  
+    if (osflags & PR_SYNC) access = OPEN_FLAGS_WRITE_THROUGH;
+ 
     if (osflags & PR_RDONLY)
         access |= OPEN_ACCESS_READONLY;
     else if (osflags & PR_WRONLY)
         access |= OPEN_ACCESS_WRITEONLY;
     else if(osflags & PR_RDWR)
         access |= OPEN_ACCESS_READWRITE;
-    if (osflags & PR_CREATE_FILE)
-        flags |= OPEN_ACTION_CREATE_IF_NEW;
-    else if (osflags & PR_TRUNCATE){
-        flags &= ~OPEN_ACTION_OPEN_IF_EXISTS;
-        flags |= OPEN_ACTION_REPLACE_IF_EXISTS;
+
+    if ( osflags & PR_CREATE_FILE && osflags & PR_EXCL )
+    {
+        flags = OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_FAIL_IF_EXISTS;
+    }
+    else if (osflags & PR_CREATE_FILE)
+    {
+        if (osflags & PR_TRUNCATE)
+            flags = OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS;
+        else
+            flags = OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS;
+    } 
+    else
+    {
+        if (osflags & PR_TRUNCATE)
+            flags = OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS;
+        else
+            flags = OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS;
     }
 
     if (isxdigit(mode) == 0) /* file attribs are hex, UNIX modes octal */
@@ -199,11 +215,11 @@
     rv = DosWrite((HFILE)fd->secret->md.osfd,
                   (PVOID)buf,
                   len,
-                  (PULONG)&bytes);
+                  (PULONG) &bytes);
 
     if (rv != NO_ERROR) 
     {
-        _PR_MD_MAP_WRITE_ERROR(rv);
+	_PR_MD_MAP_WRITE_ERROR(rv);
         return -1;
     }
 
@@ -725,7 +741,7 @@
     }
 
     if (inheritable)
-      flags &= OPEN_FLAGS_NOINHERIT;
+      flags &= ~OPEN_FLAGS_NOINHERIT;
     else
       flags |= OPEN_FLAGS_NOINHERIT;
Wan-teh,
Nice catch. The access flag should be OR'd in as you suggest. That wasn't really 
the bug we were fixing, but we saw that on Windows that check was there. Please 
make that change before checking in the fix. Thank you.
I checked in the patch, after changing "access = ..." to "access |= ...".

Main trunk
/cvsroot/mozilla/nsprpub/pr/src/md/os2/os2io.c, revision 3.7

NSPRPUB_RELEASE_4_0_BRANCH
/cvsroot/mozilla/nsprpub/pr/src/md/os2/os2io.c, revision 3.5.4.2

NSPRPUB_CLIENT_BRANCH
/cvsroot/mozilla/nsprpub/pr/src/md/os2/os2io.c, revision 3.5.18.2
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Target Milestone: --- → 4.0.1
Target Milestone: 4.0.1 → 4.0.2
Verified
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.