1Quick Summary 2------------- 3 4cd /usr/src/linux/scripts/ksymoops 5make ksymoops 6./ksymoops < the_oops.txt 7 8and send the output the maintainer of the kernel area that seems to be 9involved with the problem. Don't worry too much about getting the wrong 10person. If you are unsure send it to the person responsible for the code 11relevant to what you were doing. If it occurs repeatably try and describe 12how to recreate it. Thats worth even more than the oops 13 14If you are totally stumped as to whom to send the report, send it to 15linux-kernel@vger.rutgers.edu. Thanks for your help in making Linux as 16stable as humanly possible. 17 18Where is the_oops.txt? 19---------------------- 20 21Normally the Oops text is read from the kernel buffers by klogd and 22handed to syslogd which writes it to a syslog file, typically 23/var/log/messages (depends on /etc/syslog.conf). Sometimes klogd dies, 24in which case you can run dmesg > file to read the data from the kernel 25buffers and save it. Or you can cat /proc/kmsg > file, however you 26have to break in to stop the transfer, kmsg is a "never ending file". 27If the machine has crashed so badly that you cannot enter commands or 28the disk is not available then you have three options :- 29 30(1) Hand copy the text from the screen and type it in after the machine 31 has restarted. Messy but it is the only option if you have not 32 planned for a crash. 33 34(2) Boot with a serial console (see Documentation/serial-console.txt), 35 run a null modem to a second machine and capture the output there 36 using your favourite communication program. Minicom works well. 37 38(3) Patch the kernel with one of the crash dump patches. These save 39 data to a floppy disk or video rom or a swap partition. None of 40 these are standard kernel patches so you have to find and apply 41 them yourself. Search kernel archives for kmsgdump, lkcd and 42 oops+smram. 43 44No matter how you capture the log output, feed the resulting file to 45ksymoops along with /proc/ksyms and /proc/modules that applied at the 46time of the crash. /var/log/ksymoops can be useful to capture the 47latter, man ksymoops for details. 48 49 50Full Information 51---------------- 52 53From: Linus Torvalds <torvalds@cs.helsinki.fi> 54 55How to track down an Oops.. [originally a mail to linux-kernel] 56 57The main trick is having 5 years of experience with those pesky oops 58messages ;-) 59 60Actually, there are things you can do that make this easier. I have two 61separate approaches: 62 63 gdb /usr/src/linux/vmlinux 64 gdb> disassemble <offending_function> 65 66That's the easy way to find the problem, at least if the bug-report is 67well made (like this one was - run through ksymoops to get the 68information of which function and the offset in the function that it 69happened in). 70 71Oh, it helps if the report happens on a kernel that is compiled with the 72same compiler and similar setups. 73 74The other thing to do is disassemble the "Code:" part of the bug report: 75ksymoops will do this too with the correct tools (and new version of 76ksymoops), but if you don't have the tools you can just do a silly 77program: 78 79 char str[] = "\xXX\xXX\xXX..."; 80 main(){} 81 82and compile it with gcc -g and then do "disassemble str" (where the "XX" 83stuff are the values reported by the Oops - you can just cut-and-paste 84and do a replace of spaces to "\x" - that's what I do, as I'm too lazy 85to write a program to automate this all). 86 87Finally, if you want to see where the code comes from, you can do 88 89 cd /usr/src/linux 90 make fs/buffer.s # or whatever file the bug happened in 91 92and then you get a better idea of what happens than with the gdb 93disassembly. 94 95Now, the trick is just then to combine all the data you have: the C 96sources (and general knowledge of what it _should_ do), the assembly 97listing and the code disassembly (and additionally the register dump you 98also get from the "oops" message - that can be useful to see _what_ the 99corrupted pointers were, and when you have the assembler listing you can 100also match the other registers to whatever C expressions they were used 101for). 102 103Essentially, you just look at what doesn't match (in this case it was the 104"Code" disassembly that didn't match with what the compiler generated). 105Then you need to find out _why_ they don't match. Often it's simple - you 106see that the code uses a NULL pointer and then you look at the code and 107wonder how the NULL pointer got there, and if it's a valid thing to do 108you just check against it.. 109 110Now, if somebody gets the idea that this is time-consuming and requires 111some small amount of concentration, you're right. Which is why I will 112mostly just ignore any panic reports that don't have the symbol table 113info etc looked up: it simply gets too hard to look it up (I have some 114programs to search for specific patterns in the kernel code segment, and 115sometimes I have been able to look up those kinds of panics too, but 116that really requires pretty good knowledge of the kernel just to be able 117to pick out the right sequences etc..) 118 119_Sometimes_ it happens that I just see the disassembled code sequence 120from the panic, and I know immediately where it's coming from. That's when 121I get worried that I've been doing this for too long ;-) 122 123 Linus 124 125 126--------------------------------------------------------------------------- 127Notes on Oops tracing with klogd: 128 129In order to help Linus and the other kernel developers there has been 130substantial support incorporated into klogd for processing protection 131faults. In order to have full support for address resolution at least 132version 1.3-pl3 of the sysklogd package should be used. 133 134When a protection fault occurs the klogd daemon automatically 135translates important addresses in the kernel log messages to their 136symbolic equivalents. This translated kernel message is then 137forwarded through whatever reporting mechanism klogd is using. The 138protection fault message can be simply cut out of the message files 139and forwarded to the kernel developers. 140 141Two types of address resolution are performed by klogd. The first is 142static translation and the second is dynamic translation. Static 143translation uses the System.map file in much the same manner that 144ksymoops does. In order to do static translation the klogd daemon 145must be able to find a system map file at daemon initialization time. 146See the klogd man page for information on how klogd searches for map 147files. 148 149Dynamic address translation is important when kernel loadable modules 150are being used. Since memory for kernel modules is allocated from the 151kernel's dynamic memory pools there are no fixed locations for either 152the start of the module or for functions and symbols in the module. 153 154The kernel supports system calls which allow a program to determine 155which modules are loaded and their location in memory. Using these 156system calls the klogd daemon builds a symbol table which can be used 157to debug a protection fault which occurs in a loadable kernel module. 158 159At the very minimum klogd will provide the name of the module which 160generated the protection fault. There may be additional symbolic 161information available if the developer of the loadable module chose to 162export symbol information from the module. 163 164Since the kernel module environment can be dynamic there must be a 165mechanism for notifying the klogd daemon when a change in module 166environment occurs. There are command line options available which 167allow klogd to signal the currently executing daemon that symbol 168information should be refreshed. See the klogd manual page for more 169information. 170 171A patch is included with the sysklogd distribution which modifies the 172modules-2.0.0 package to automatically signal klogd whenever a module 173is loaded or unloaded. Applying this patch provides essentially 174seamless support for debugging protection faults which occur with 175kernel loadable modules. 176 177The following is an example of a protection fault in a loadable module 178processed by klogd: 179--------------------------------------------------------------------------- 180Aug 29 09:51:01 blizard kernel: Unable to handle kernel paging request at virtual address f15e97cc 181Aug 29 09:51:01 blizard kernel: current->tss.cr3 = 0062d000, %cr3 = 0062d000 182Aug 29 09:51:01 blizard kernel: *pde = 00000000 183Aug 29 09:51:01 blizard kernel: Oops: 0002 184Aug 29 09:51:01 blizard kernel: CPU: 0 185Aug 29 09:51:01 blizard kernel: EIP: 0010:[oops:_oops+16/3868] 186Aug 29 09:51:01 blizard kernel: EFLAGS: 00010212 187Aug 29 09:51:01 blizard kernel: eax: 315e97cc ebx: 003a6f80 ecx: 001be77b edx: 00237c0c 188Aug 29 09:51:01 blizard kernel: esi: 00000000 edi: bffffdb3 ebp: 00589f90 esp: 00589f8c 189Aug 29 09:51:01 blizard kernel: ds: 0018 es: 0018 fs: 002b gs: 002b ss: 0018 190Aug 29 09:51:01 blizard kernel: Process oops_test (pid: 3374, process nr: 21, stackpage=00589000) 191Aug 29 09:51:01 blizard kernel: Stack: 315e97cc 00589f98 0100b0b4 bffffed4 0012e38e 00240c64 003a6f80 00000001 192Aug 29 09:51:01 blizard kernel: 00000000 00237810 bfffff00 0010a7fa 00000003 00000001 00000000 bfffff00 193Aug 29 09:51:01 blizard kernel: bffffdb3 bffffed4 ffffffda 0000002b 0007002b 0000002b 0000002b 00000036 194Aug 29 09:51:01 blizard kernel: Call Trace: [oops:_oops_ioctl+48/80] [_sys_ioctl+254/272] [_system_call+82/128] 195Aug 29 09:51:01 blizard kernel: Code: c7 00 05 00 00 00 eb 08 90 90 90 90 90 90 90 90 89 ec 5d c3 196--------------------------------------------------------------------------- 197 198Dr. G.W. Wettstein Oncology Research Div. Computing Facility 199Roger Maris Cancer Center INTERNET: greg@wind.rmcc.com 200820 4th St. N. 201Fargo, ND 58122 202Phone: 701-234-7556 203

