How to debug FUSE filesystem crash in Linux

Hrishi picture Hrishi · Dec 9, 2009 · Viewed 11.7k times · Source

Currently I am developing an application using FUSE filesystem module in Linux (2.6 Kernel) in C language. Due to some programming error, the application crashes after mounting the filesystem. Since I am a novice developer in Linux/C environment. Could you please let me tell me possible options to debug such programs?

Answer

br1ckd picture br1ckd · Mar 15, 2013

There are a couple features of FUSE that can make it difficult to debug: it normally runs in the background (which means it detaches from stdin/out) and is multithreaded (which can introduce race conditions and is more complicated to debug with gdb). Luckily, both features can be disabled:

  1. Use the -f switch to keep your application in the foreground. This will make your printf lines work.
  2. Use the -s switch to disable multithreading. Disabling multithreading will limit performance, but will also hide certain bugs (race conditions), simplify the use of gdb, and ensure printf output is readable (when multiple threads call printf at about the same time their output can get mixed up).

I'd also recommend reading Geoff Kuenning's FUSE documentation.