Re: silly minor bug in i386/mm/fault.c, 2.0.34, 2.1.106

Andreas Schwab (schwab@issan.informatik.uni-dortmund.de)
13 Jul 1998 10:55:46 +0200


"Michael L. Galbraith" <mikeg@weiden.de> writes:

|> On Tue, 7 Jul 1998, Neil Conway wrote:
|>
|> > Dunno how I never noticed the garbage character before, on the
|> > "Unable to handle kernel paging request" messages...
|> >
|> > The printk isn't working for some reason (dunno why though ;-). Here's
|> > the code snippet from do_page_fault():
|> >
|> > __asm__("movl %%cr3,%0" : "=r" (page));
|> > printk(KERN_ALERT "current->tss.cr3 = %08lx, %%cr3 = %08lx\n",
|> > tsk->tss.cr3, page);
|> >
|> > The %%cr3 bit should print >> %cr3 << to the screen, (unless I've
|> > really
|> > lost it), but it actually gets interpreted by some layer inside the
|> > printk()
|> > as a %c, which means that you get a random character being written
|> > instead.
|> >
|> > (Aside, I dunno why that doesn't bugger up the "page" value being
|> > printed
|> > out too, cos I thought printf() and the like advanced their pointers
|> > every
|> > time they used one of their arguments ??)
|>
|> Hi,
|>
|> The output to the screen prints correctly here. It's the one to syslog
|> that gets munged. I always got |r3 until I recompiled klogd (today)..
|> now with the new one I get 8r3.

Here is a patch for sysklogd-1.3 that fixes the problem:

--- sysklogd-1.3/klogd.c.~2~ Sat Feb 1 17:52:43 1997
+++ sysklogd-1.3/klogd.c Fri Jul 10 20:58:23 1998
@@ -379,7 +379,6 @@
{
fputs("Logging line:\n", stderr);
fprintf(stderr, "\tLine: %s\n", fmt);
- fprintf(stderr, "\tPriority: %c\n", *(fmt+1));
}

/* Handle output to a file. */
@@ -395,6 +394,33 @@
}

/* Output using syslog. */
+ va_start(ap, fmt);
+ vsyslog(priority, fmt, ap);
+ va_end(ap);
+
+ return;
+}
+
+void Syslog1(int priority, char *fmt)
+{
+ if ( debugging )
+ {
+ fputs("Logging line:\n", stderr);
+ fprintf(stderr, "\tLine: %s\n", fmt);
+ fprintf(stderr, "\tPriority: %c\n", *(fmt+1));
+ }
+
+ /* Handle output to a file. */
+ if ( output_file != (FILE *) 0 )
+ {
+ fputs(fmt, output_file);
+ fputc('\n', output_file);
+ fflush(output_file);
+ fsync(fileno(output_file));
+ return;
+ }
+
+ /* Output using syslog. */
if ( *fmt == '<' )
{
switch ( *(fmt+1) )
@@ -427,9 +453,7 @@
fmt += 3;
}

- va_start(ap, fmt);
- vsyslog(priority, fmt, ap);
- va_end(ap);
+ syslog(priority, "%s", fmt);

return;
}
@@ -481,7 +505,7 @@
{
memset(eline, '\0', sizeof(eline));
ExpandKadds(line, eline);
- Syslog(LOG_INFO, eline);
+ Syslog1(LOG_INFO, eline);
}
index = 0;
memset(line, '\0', sizeof(line));

-- 
Andreas Schwab                                      "And now for something
schwab@issan.informatik.uni-dortmund.de              completely different"
schwab@gnu.org

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html