[cfe-dev] Illegal instruction problem

Philip Ashmore contact at philipashmore.com
Tue Nov 29 12:25:16 PST 2011


Sorry Chris for sending this to you personally before - I meant to send 
it to the list.

On 28/11/11 14:40, Chris Lattner wrote:
>
> On Nov 27, 2011, at 6:02 PM, Philip Ashmore wrote:
>
>> Hi there.
>>
>> I've just committed new versions of some of my packages in SourceForge:
>>
>> v3c-2.2.0-01
>> treedb-1.2.0-02
>> meta-treedb-1.3.0-03
>>
>> I've got a problem with the release build (which uses -03 optimisation)
>> of treedb.
>>
>> The "fuse" tests fail with an illegal instruction fault.
>
> Hi Philip,
>
> The most likely cause of this is that you're using undefined behavior 
> (e.g. an uninitialized variable, array out of bounds, etc) in your 
> code that the optimizer is detecting.  Please see:
> http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html
>
> for more information.
>
> -Chris
OK. Well, I did find a problem in v3c with valgrind - I'll push a new 
release after writing
this. It has nothing to do with this problem though - fcntl(F_GETLK) 
doesn't set l_pid if
there's no lock.

Unfortunately valgrind can't go through setuid/setgid programs, which is 
what the fuse library does
- it runs fusermount, so I couldn't valgrind the whole test.

So I tried another way.

1. In treedb
    $ cd build/v3c/3-comet
    $ mkdir fuse
2. Run the daemon in foreground mode on the "fuse" directory and add 
debug output 'cause we can:
    $ TREEDB_FUSE_TMPDIR=$(readlink -f .) LD_LIBRARY_PATH=.libs:../.libs 
./lt-treedb-malloc-daemon-d -d fuse
3. Debug malloc-test-d
    $ kdbg .libs/malloc-test-d
4. Set the command line argument to reserve a 50M heap : 
kdbg->Execution->Arguments 50M
5. Set environment variables in kdbg->Execution->Arguments->Environment
    LD_LIBRARY_PATH=.libs:../.libs
    V3C_TREEDB_MALLOC_FUSE_DIR=fuse
6. Run the program kdbg->Execution->Run or F5

It hit an "ud2" instruction - kdbg reports SIGILL - Illegal instruction, 
at treedb's v3c/avl-impl.h line
227, in treedb_malloc_AvlAllocator_used_insert_node_after_64 - the 
function name is a macro expansion
and I've expanded it here as that's what's in the stack trace.

Unfortunately v3c/avl-impl.h line 227 isn't in the above function - it's 
inside
AVL_TREE_NS(unpack_node)(...) - I won't expand the macro-mangled name here.

So either kdbg-2.5.0-1 is wrong (not impossible) or the debug 
information or llvm/clang is wrong.

Is it asking too much to take a look?

Regards,
Philip Ashmore




More information about the cfe-dev mailing list