Tag Info

Hot answers tagged

25

A segmentation fault is the result of a memory access violation. The program has referred to a memory address outside of what was allocated to it, and the OS kernel responds by killing the program with SIGSEGV. This is a mistake, since there is no point in trying to access inaccessible memory (it cannot be done). Mistakes of this sort are easy to make, ...


18

You can stop both processing by sending them SIGSTOP (replace pid1 and pid2 by the actual PIDs or use killall and the application name): kill -SIGSTOP pid1 pid2 The printing on the terminal (or wherever stdout is redirected to) should stop. Then continue one of them using kill -SIGCONT pid1 If the error messages appear immediately, you know its the ...


17

There isn't a universal way, but you can make an educated guess by looking for things only done by one compiler. GCC is the easiest; it writes a .comment section that contains the GCC version string (the same string you get if you run gcc --version). I don't know if there's a way to display it with readelf, but with objdump it's: objdump -s --section ...


13

Many of the flags that can be passed to bash on the command line are set flags. set is the shell built-in which can toggle these flags at runtime. For example, calling a script as bash -x foo.sh is basically the same as doing set -x at the top of the script. Knowing that set is the shell built-in responsible for this lets us know where to look. Now we can ...


12

My personal flavor for Linux Kernel development is Debian. Now for your points: As you probably guessed Ubuntu doesn't bring nothing new to kernel ease kernel development afaik, apart from what's already available in Debian. For e.g. make_kpkg is a Debian feat. and not Ubuntu. Here are some links to get you started on common Linux Kernel development tasks ...


11

On Linux, assuming you want to know what is writing to the same resource as your shell's stdout is connected to, you could do: strace -fe write $(lsof -t "/proc/$$/fd/1" | sed 's/^/-p/') That would report the write() system calls (on any file descriptor) of every process that have at least on file descriptor open on the same file as fd 1 of your shell.


10

If you can change the source code, Dmalloc is great; it will list which pointers were unfreed and (for code built with debugging symbols) exactly which line they were allocated on. If you can't, Valgrind is pretty much the standard for that sort of thing. I generally find Valgrind somewhat harder to use, but it has way more features and doesn't involve ...


10

You can only debug a setuid or setgid program if the debugger is running as root. The kernel won't let you call ptrace on a program running with extra privileges. If it did, you would be able to make the program execute anything, which would effectively mean you could e.g. run a root shell by calling a debugger on /bin/su. If you run Gdb as root, you'll be ...


10

This reference seems to have answers to your questions, titled: Linux Kernel Development Second Edition. excerpt printk() The kernel print function, printk(), behaves almost identically to the C library printf() function. Indeed, throughout this book we have not made use of any real differences. For most intentions, this is fine; printk() is simply ...


9

You've asked way too much in one question—well, technically not, as I guess "is this understanding correct" can be answered quickly: no. But that's not a useful answer. First, you're right about ata_piix and sd_mod apparently being compiled-in to your kernel. That's a choice you make configuring the kernel—you can omit it, include it, or include it as a ...


8

There is a system call named ptrace. It takes 4 parameters: the operation, the PID of the target process, an address in the target process memory, and a data pointer. The way the last 2 parameters are used is dependent on the operation. For example you can attach/detach your debugger to a process: ptrace(PTRACE_ATTACH, pid, 0, 0); ... ptrace(PTRACE_DETACH, ...


8

The methods will depend on the kind of the problem. In general "How To Ask Questions The Smart Way" by Eric S. Raymond and Rick Moen is sometimes a helpful advice to focus on the problem and to check if you have thought about important parts of the problem. Your first source of information during debugging are the logfiles your system/application writes. ...


8

There are many ways to handle suspend and hibernate capabilities, many of the old methods are deprecated. This has made searching for solutions difficult, as it seems every solution is completely unrelated to the next. With that said... The method currently recommended, advocated from http://pm-utils.freedesktop.org/wiki/, should be available for most ...


8

ltrace -- A library call tracer. It only works on Linux and in a small subset of architectures. Calls to dlopen()ed libraries will not be traced. Further pointers from man page and /etc/ltrace.conf


8

I think, general principles of network troubleshooting are: Find out at what level of TCP/IP stack(or some other stack) occurs the problem. Understand what is the correct system behavior, and what is deviation from normal system state Try to express the problem in one sentence or in several words Using obtained information from buggy system, your own ...


8

One hacky way is just to write your comments as arguments to a no-op command. Particularly useful might be the : null utility: set -x : Some interesting notes on the following are ... results in: + : Some interesting notes on the following are... The colon command does nothing, accepts whatever arguments you give it, and always succeeds. You get an ...


8

You can do this with gdb: commands ni and si run a single instruction at time. Command n runs the next line of code, for most values of "next". For n (and the corresponding s) you have to have compiled so that debugging symbols appear in the executable. This stackoverflow answer gives a couple of methods of doing this more-or-less visually. The gdb ...


7

valgrind is amazingly helpful.


7

xtrace output goes to stderr, so you could redirect stderr to /dev/null: ikwtd() { echo do stuff } 2> /dev/null If you still want to see the errors from the commands run inside the functions, you could do ikwtd() ( set +x exec 2>&3 3>&- echo do stuff ) 3>&2 2> /dev/null See also this locvar.sh which contains a few ...


6

First things first, debug the module? Just see if you can load it up in gdb it might point you straight at a line that uses the relevant variable(or close to it). oh, and you might find this article useful


6

As far as i know there is no way to directly do that as cron has a special purpose - running schedules commands at a specific time. So the best thing is to either to manually create a crontab entry or write a script which removes and resets the environment.


6

Use less. Start less on the text file you want to monitor: less some_file If you want to search for a pattern, ues a slash to start a search a pattern: /<pattern> # forward search ?<pattern> # backward search If you want to filter the output use an ampersand: &<pattern> Then start the continuous output using shiftf. You can ...


5

You can try using the strings command. It will create a lot of text output; by checking it you might guess the compiler. pubuntu@pubuntu:~$ strings -a a.out |grep -i gcc GCC: (Ubuntu 4.4.3-4ubuntu5) 4.4.3 Here I know it's compiled with gcc but you can always redirect strings output to a file and examine it. There is one very good utility called peid ...


5

Arch is a DIY distro: there is no automated tool for bug reporting. There is, however, comprehensive guidance on the Arch Wiki for reporting bugs. The philosophy of Arch, the Arch Way, stresses self-sufficiency and a willingness to contribute solutions, which means actively participating in bug reporting and squashing. This doesn't fit well with an ...


5

Sometimes ltrace works. In general, this calls for a debugger such as GDB. You can get an idea of which functions to put trace points or break points on by looking at the call structure in the disassembly (objdump -d /path/to/executable).


5

Try starting with strace. When one program calls another, it uses one of the exec system calls. For instance, given the following ruby script: #!/usr/bin/env ruby system("ls") system("df") I can grep strace output to find out what executables it runs: $ strace -f ./test.rb 2>&1 | grep exec execve("./test.rb", ["./test.rb"], [/* 23 vars */]) = 0 ...


4

How about: readelf -p .comment a.out


4

I'm one of the authors of that patch, sorry it is so buggy :) In general to find null pointers like this I just insert printks until I find the pointer that is null (=0), then I read the source code until I find out why. However in this case I know that you have to disable framebuffer console or you'll get this nasty bug, which is only triggered when the ...


4

Uh, how do you know about the segfault anyway? There is a kernel log message at priority info. It shows the executable name without the directory part. On some architectures, the debug.exception-trace sysctl must be set. Some architectures require a compile-time option and kernel command line parameter (e.g. CONFIG_USER_DEBUG and user_debug on arm).


4

run ulimit -c 1073741824 prior to starting the program. Next time the program crashes, a core dump will be created in the working directory (named core.). You can then use GDB to open this core at any time you like. ulimit -c XXXXX sets the maximum size of the core dump file created when a program seg faults. By default this is '0' which means not to dump ...



Only top voted, non community-wiki answers of a minimum length are eligible