[Parted-maintainers] Bug#602568: squeeze-di-beta1 installer: partman hang
Jean-Christian de Rivaz
jc at eclis.ch
Mon Nov 8 10:02:59 UTC 2010
Christian PERRIER a écrit :
> THanks *a lot* for this very detailed analysis. It really seems that
> your fix should make it into parted.
Thanks for your support. It's good to hear someone :-)
I have tested the compilation of the
http://ftp.de.debian.org/debian/pool/main/p/parted/parted_2.3.orig.tar.gz
archive, without the Debian patches and found the same observation. I
now use this simple configure command to get a big static executable
(this is more easy for the dubug:
CFLAGS="-g" ./configure --disable-shared --enable-static
I have tested each optimization option: -O0 -O -O1 -O2 -O3 -Os. I found
that the bug appear only with -O0 or no optimization option at all. Any
other optimization flag produce a executable that do not expose the bug.
Next I tested with valgrind:
==27947== Conditional jump or move depends on uninitialised value(s)
==27947== at 0x8065619: ped_geometry_new (geom.c:78)
==27947== by 0x8065701: ped_geometry_duplicate (geom.c:107)
==27947== by 0x80665E3: ped_constraint_init (constraint.c:75)
==27947== by 0x8066695: ped_constraint_new (constraint.c:104)
==27947== by 0x80978BA: _primary_constraint (dos.c:1653)
==27947== by 0x8097F70: _align_primary (dos.c:1814)
==27947== by 0x809858A: _align (dos.c:1966)
==27947== by 0x8098A8E: msdos_partition_align (dos.c:2083)
==27947== by 0x80623CA: _partition_align (disk.c:922)
==27947== by 0x8064779: ped_disk_add_partition (disk.c:2021)
==27947== by 0x8095D88: read_table (dos.c:935)
==27947== by 0x8095F8F: msdos_read (dos.c:987)
Time to start the debugger. The attached image give a complete picture
of the problem.
* On the left parted is compiled with -O1 optimization.
* On the right parted in compiled with -O0 optimization.
With optimization (left) the start_geom structure is magically
initialized with god enough value right at the beginning of the
_primary_constraint() function. In particular start_geom->dev is a valid
value. Without optimization start_geom contain uninitialized values at
the beginning of the _primary_constraint() function, as expected.
In the two executable, the relevant variables as set this way:
min_geom = 0
cylinder_size = 16065
dev->length = 10240
So the "if (min_geom)" is not taken and in the "else", the "if
(cylinder_size < dev->length && ...)" is not taken either. This cause
the start_geom untouched because it was never passed to any
ped_geometry_init() function.
But as with optimization start_geom contain magically good values, it
somewhere work or at least do not crash. Without optimization min_geom
contain garbage and produce a crash. It should be noted that the
start_geom->dev could contain a garbage other than zero. This will
certainly produce a more spectacular crash of parted.
Any parted specialist here ? How start_geom should be initialized in
case min_geom==0 && cylinder_size < dev->length ?
A moral of this story is to never trust optimized executable, even when
there seem to work better that not optimized one.
Jean-Christian de Rivaz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Capture-parted-2.3.png
Type: image/png
Size: 225797 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/parted-maintainers/attachments/20101108/d3b0d9c8/attachment-0001.png>
More information about the Parted-maintainers
mailing list