[guardian-dev] debugging libsqlfs

Hans-Christoph Steiner hans at guardianproject.info
Mon Jan 7 21:50:58 EST 2013

Hey Abel,

I'm now diving in deep into debugging using gdb for now.  I've been catching
crashed in sqlfs with gdb and can get backtraces.  For the record, here's how
I'm doing it:

* using a VM to avoid filesystem crashes and lock-ups :)

* to mount the file system, run this as root:
	gdb --args ./.libs/fuse_sqlfs -d -o allow_other /mnt/

* to test it, run this as a normal user:
	./libsqlfs/tests/fsx  -l 10485760 -o 1048576  /mnt/testfile8

Most of the backtraces look like this, i.e. occuring in sqlfs_proc_trunctate()
with sqlfs=sqlfs at entry=0x0:

#1  0xb7ede033 in get_value_block (sqlfs=sqlfs at entry=0x8072b10,
    key at entry=0x805a618 "/testfile8",
block_no=block_no at entry=63, size=size at entry=0x0) at sqlfs.c:1326
#2  0xb7edee28 in get_value (sqlfs=0x8072b10, key=key at entry=0x805a618
    value=value at entry=0xb7504fb4, begin=8257536, begin at entry=0, end=8321722,
end at entry=0)
    at sqlfs.c:1487
#3  0xb7ee36f9 in sqlfs_proc_truncate (sqlfs=sqlfs at entry=0x0,
path=path at entry=0x805a618 "/testfile8",
    size=0) at sqlfs.c:2545
#4  0xb7ee3fb3 in sqlfs_op_truncate (path=0x805a618 "/testfile8", size=0) at
#5  0xb7ef980a in fuse_fs_truncate () from /lib/i386-linux-gnu/libfuse.so.2

It seems that sqlfs_t gets re-issued a lot, I added this to get_sqlfs() and
got it many many times:

    if (p)
        return p;
        show_msg(stderr, "sqlfs was 0");

This lead me to examine the threading stuff, since it seems that when sqlfs ==
0, its getting a new sqlfs issued from:

    sqlfs = (sqlfs_t *) (pthread_getspecific(sql_key));

Since the libsqlfs code only has pthread code relating to the pthread_key_t
creation and use, my guess is that FUSE itself is handling the rest of the
threading.  So the good news is that libsqlfs was made with threading in mind,
the bad news is that a lot of it is normally handled in libfuse, so we'll have
to figure that part out and implement it in IOCipher in order to support threads.

Now, I'm going to see if I can get valgrind to run on fuse_sqlfs.


More information about the Guardian-dev mailing list