Skip to contentSkip to conversation

salinfo-0.4 patch

PATCH Ben Woodard 2 participants 4 messages Jan 28, 2004 – Jan 30, 2004

lore
Share & tools
lore
#0 lore raw

Here is a tiny patch for salinfo-0.4. There is a problem with when it deals with multiple errors. The decoded error messages fill up with progressively more white space.

The problem seems to be that the indent variable doesn't get cleared between errors and so the indent level gets progressively deeper until the file grows to astronomical purportions. My understanding from the sys admins is that when we first booted up some machines with a salinfo daemon about half of them crashed because the backlog of errors that had accumulated in the SAL. As the salinfo_decode daemon processed these sequentially, and the level of indenting grew, the size of the decoded files in /var/log/salinfo grew to several megabytes each and quickly filled up /var and then bad things happened.

While poking around in the iprint function, I also found an error message that looks like it is better suited for stderr rather than stdout so I retargetted it.

mca.c +4 -3
diff -ru salinfo-0.4/mca.c salinfo-0.4-ben/mca.c
@@ -104,8 +104,9 @@
 				fputs("  ", stdout);
 			startofline = 0;
 			if (++iprintf_count > 1000000 /* arbitrary */) {
-				printf("\n\nError: iprintf line count exceeded, aborting output\n\n");
-				fflush(stdout);
+				fprintf(stderr,
+					"\n\nError: iprintf line count exceeded, aborting output\n\n");
+				fflush(stderr);
 				exit(1);
 			}
 		}
@@ -1502,7 +1503,7 @@
 	decode_oem_cpu = cpu;
 	decode_oem_oemdata_fd = oemdata_fd;
 
-	iprintf_count = 0;
+	iprintf_count = indent = 0;
 
 	if (debug > 1)
 		prt_record_header(lh);
#1 lore raw
Quoted 3 lines · Ben Woodard

Here is a tiny patch for salinfo-0.4. There is a problem with when it deals with multiple errors. The decoded error messages fill up with progressively more white space.

That should not occur, the ++indent/--indent lines should be matched. Instead of forcing indent back to 0, please find the missing line and fix it. Correct code is better than an arbitrary reset.

If you have a sample of nested indent that will help track down the bug, send it to [email protected].

Quoted 3 lines

While poking around in the iprint function, I also found an error message that looks like it is better suited for stderr rather than stdout so I retargetted it.

No. I deliberately used stdout so the error message would appear at the end of the truncated file on disk, to tell the viewer that this particular file was incomplete. stderr is useless when salinfo_decode is run from init.d.

#2 lore raw
In reply to Ben Woodard
Quoted 13 lines · Keith Owens
Quoted 3 lines · Ben Woodard

Here is a tiny patch for salinfo-0.4. There is a problem with when it deals with multiple errors. The decoded error messages fill up with progressively more white space.

That should not occur, the ++indent/--indent lines should be matched. Instead of forcing indent back to 0, please find the missing line and fix it. Correct code is better than an arbitrary reset.

If you have a sample of nested indent that will help track down the bug, send it to [email protected].

Quoted 8 lines
Quoted 3 lines

While poking around in the iprint function, I also found an error message that looks like it is better suited for stderr rather than stdout so I retargetted it.

No. I deliberately used stdout so the error message would appear at the end of the truncated file on disk, to tell the viewer that this particular file was incomplete. stderr is useless when salinfo_decode is run from init.d.

OK how about this patch. I think I found the missing --indent.

01/28 23:28:27 renamed from 01/28 23:28:03 1.1 +1 -0
diff -u -r1.1 mca.c
@@ -857,6 +857,7 @@
        }
        if (pcei->valid.oem_data)
                platform_pci_comp_err_print(&pcei->header, p_oem_data);
+       --indent;
 }
  
 /* Format and log the platform specifie error record section data */
#3 lore raw
In reply to Ben Woodard

How about this:

mca.c 2004-01-29 14:13:25.000000000 -0800 renamed from mca.c 2003-12-04 12:03:18.000000000 -0800 +3 -1
diff -ru salinfo-0.4/mca.c salinfo-0.4-new/mca.c
@@ -834,7 +834,7 @@
                iprintf("Invalid PCI Component Error Record format: length = %d, "
                       " Size PCI Data = %ld, Num Mem-Map/IO-Map Regs = %d/%d\n",
                       pcei->header.len, n_pci_data, n_mem_regs, n_io_regs);
-               return;
+               goto out;
        }
  
        if (n_mem_regs) {
@@ -857,6 +857,8 @@
        }
        if (pcei->valid.oem_data)
                platform_pci_comp_err_print(&pcei->header, p_oem_data);
+ out:
+       --indent;
 }
  
 /* Format and log the platform specifie error record section data */

Only in salinfo-0.4-new/: mca.c~
Only in salinfo-0.4-new/: mca.c,v

salinfo_decode.c 2004-01-29 15:14:50.000000000 -0800 renamed from salinfo_decode.c 2003-11-24 14:37:28.000000000 -0800 +7 -2
diff -ru salinfo-0.4/salinfo_decode.c salinfo-0.4-new/salinfo_decode.c
@@ -276,10 +276,15 @@
                        cpu,
                        type,
                        suffix);
-               if (!(freopen(filename, "w", stdout) && freopen(filename, "w", stderr))) {
-                       perror(filename);
+               if ((fd = open(filename, O_WRONLY|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR)) < 0){
+                       perror(filename);
                        goto out;
                }
+               if ( dup2(fd,1) != 1 && dup2(fd,2) != 2){
+                       perror(filename);
+                       goto out;
+               }
+               close(fd);
  
                printf("BEGIN HARDWARE ERROR STATE from %s on cpu %d\n", type, cpu);
                platform_info_print(buffer, 1, fd_data, cpu, oemdata_fd);

I found another bug that I tripped over. Evidently when running as a daemon the freopen fails because the file is closed or something. I didn't investigate the error state carefully. When it tries to do a write later on in response to one of the printfs, it barfs and says gets an error with EPIPE and the program monitoring that class of bugs exits. Obviously this problem disappears if you run salinfo_decode interactively.

Doing the open and the dup2's seems to fix that problem but it hasn't been extensively tested. We have this tiny little problem with the whole salinfo system. It hangs the system.

When we ran the salinfo_decode code interactively it seemed to hang the system because it was getting hung up on the freopen. However, when we ran it with the init script and it made a daemon, then the system appeared to stay up. It turns out that this was only because the CPE version of salinfo_decode was exiting when it got the the freopen. Therefore it was never getting to the bug (which Jim and I think is likely a race condition of some kind) that hangs the system.

Now that I fixed the problem with freopen running as a daemon and the salinfo_decode program gets beyond that point even when it is running in a daemon mode, we are hanging the system almost every single time now.

Jim is looking for more race conditions and for ways to fix the ones he already sees. I will be working on that as well on Monday.

-ben

Quoted 24 lines · Keith Owens
Quoted 1 line · Ben Woodard

It is a race, let's see who can find the missing --indent first. ;-)

mca.c renamed from mca.c.old +3 -1
@@ -834,7 +834,7 @@
 		iprintf("Invalid PCI Component Error Record format: length = %d, "
 		       " Size PCI Data = %ld, Num Mem-Map/IO-Map Regs = %d/%d\n",
 		       pcei->header.len, n_pci_data, n_mem_regs, n_io_regs);
-		return;
+		goto out;
 	}
 
 	if (n_mem_regs) {
@@ -857,6 +857,8 @@
 	}
 	if (pcei->valid.oem_data)
 		platform_pci_comp_err_print(&pcei->header, p_oem_data);
+out:
+	--indent;
 }
 
 /* Format and log the platform specifie error record section data */