Electric fence puzzle



While trying to track down some pixbuf loader crashes, I stumbled over
the follwing problem: Using Electric Fence under gdb seems to affect
floating point arithmetic. 

Here is a very condensed example:

    matthias linux:~/gnome/gtk+/gdk-pixbuf> cat test-random.c
    #include <glib.h>
    
    #define D 2.3283064365386962890625e-10
    
    int main (int argc, char *argv[])
    {
      g_print ("%g %g %g\n", D, D * D, D + D * D);
    
      return 0;
    }
    
    matthias linux:~/gnome/gtk+/gdk-pixbuf> gcc -g -O2 -o test-random
    test-random.c `pkg-config --cflags --libs glib-2.0`
    
    matthias linux:~/gnome/gtk+/gdk-pixbuf> ./test-random
    2.32831e-10 5.42101e-20 2.32831e-10
    
    matthias linux:~/gnome/gtk+/gdk-pixbuf> gdb
    ./test-random             
    GNU gdb 20010316
    Copyright 2001 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and
    you are
    welcome to change it and/or distribute copies of it under certain
    conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB.  Type "show warranty" for
    details.
    This GDB was configured as "i386-suse-linux"...
    (gdb) run
    Starting program: /home/matthias/gnome/gtk+/gdk-pixbuf/./test-random
    2.32831e-10 5.42101e-20 2.32831e-10
    
    Program exited normally.
    (gdb)quit
    

So far everything seems normal. Now repeat the same with Electric Fence:

    matthias linux:~/gnome/gtk+/gdk-pixbuf> gcc -g -O2 -o test-random
    test-random.c `pkg-config --cflags --libs glib-2.0` -lefence
    
    matthias linux:~/gnome/gtk+/gdk-pixbuf> ./test-random
    
      Electric Fence 2.2.0 Copyright (C) 1987-1999 Bruce Perens
    <bruce perens com>
    2.32831e-10 5.42101e-20 2.32831e-10
    matthias linux:~/gnome/gtk+/gdk-pixbuf> gdb ./test-random 
    GNU gdb 20010316
    Copyright 2001 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and
    you are
    welcome to change it and/or distribute copies of it under certain
    conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB.  Type "show warranty" for
    details.
    This GDB was configured as "i386-suse-linux"...
    (gdb) run
    Starting program: /home/matthias/gnome/gtk+/gdk-pixbuf/./test-random
    [New Thread 1024 (LWP 10609)]
    
      Electric Fence 2.2.0 Copyright (C) 1987-1999 Bruce Perens
    <bruce perens com>
    2.32831e-10 5.42101e-20 nan
    
    Program exited normally.
    (gdb) quit
    
Note that when run under gdb, the last double is nan. Why is that ?

Matthias






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]