oops-tracing.txt 11 KB

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