Hilko Bengen
2011-Apr-27 22:20 UTC
[Libguestfs] [PATCH] hivex/python fix for i386 integer size issue
Hi, While working on Debian packages of hivex 1.2.5, I came across a test failure for the Python bindings with Python 2.7 on the i386 architecture. (The tests ran fine on amd64.) ,---- | $ make -C python check | make[1]: Entering directory `/home/bengen/src/deb/hivex/hivex.git/python' | 010-import.py | 020-open.py | 021-close.py | 200-write.py | python: hivex-py.c:52: get_handle: Assertion `obj' failed. `---- I narrowed this down to hivex-py.c:py_hivex_node_add_child(): The call ,---- | PyArg_ParseTuple (args, (char *) "OLs:hivex_node_add_child", | &py_h, &parent, &name) `---- results in `py_h' set to NULL, though Python's documentation claims that this cannot happen. I think this happens because `parent' is declared a `long int', but "L" in the format string corresponds to a `long long'. On amd64, they have the same size, but on i386 they don't, so the PyObject pointer is written to the wrong address. Please consider applying the patch below which just changes the format string. After regenerating hivex-py.c, I have successfully tested the 1.2.5 code base on both architectures. Cheers, -Hilko diff --git a/generator/generator.ml b/generator/generator.ml index 7e706d1..9722312 100755 --- a/generator/generator.ml +++ b/generator/generator.ml @@ -2875,7 +2875,7 @@ put_val_type (char *val, size_t len, hive_type t) pr "O" | ANode n | AValue n -> - pr "L" + pr "l" | AString n -> pr "s" | AStringNullable n ->
Richard W.M. Jones
2011-Apr-28 07:49 UTC
[Libguestfs] [PATCH] hivex/python fix for i386 integer size issue
On Thu, Apr 28, 2011 at 12:20:08AM +0200, Hilko Bengen wrote:> Hi, > > While working on Debian packages of hivex 1.2.5, I came across a test > failure for the Python bindings with Python 2.7 on the i386 > architecture. (The tests ran fine on amd64.) > > ,---- > | $ make -C python check > | make[1]: Entering directory `/home/bengen/src/deb/hivex/hivex.git/python' > | 010-import.py > | 020-open.py > | 021-close.py > | 200-write.py > | python: hivex-py.c:52: get_handle: Assertion `obj' failed. > `---- > > I narrowed this down to hivex-py.c:py_hivex_node_add_child(): > > The call > > ,---- > | PyArg_ParseTuple (args, (char *) "OLs:hivex_node_add_child", > | &py_h, &parent, &name) > `---- > > results in `py_h' set to NULL, though Python's documentation claims that > this cannot happen. I think this happens because `parent' is declared a > `long int', but "L" in the format string corresponds to a `long long'. > On amd64, they have the same size, but on i386 they don't, so the > PyObject pointer is written to the wrong address. > > Please consider applying the patch below which just changes the format > string. After regenerating hivex-py.c, I have successfully tested the > 1.2.5 code base on both architectures. > > Cheers, > -Hilko > > diff --git a/generator/generator.ml b/generator/generator.ml > index 7e706d1..9722312 100755 > --- a/generator/generator.ml > +++ b/generator/generator.ml > @@ -2875,7 +2875,7 @@ put_val_type (char *val, size_t len, hive_type t) > pr "O" > | ANode n > | AValue n -> > - pr "L" > + pr "l" > | AString n -> > pr "s" > | AStringNullable n ->Elizabeth, can you try this to see if it fixes your problem too? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
Richard W.M. Jones
2011-Apr-28 08:39 UTC
[Libguestfs] [PATCH] hivex/python fix for i386 integer size issue
On Thu, Apr 28, 2011 at 12:20:08AM +0200, Hilko Bengen wrote:> Hi, > > While working on Debian packages of hivex 1.2.5, I came across a test > failure for the Python bindings with Python 2.7 on the i386 > architecture. (The tests ran fine on amd64.) > > ,---- > | $ make -C python check > | make[1]: Entering directory `/home/bengen/src/deb/hivex/hivex.git/python' > | 010-import.py > | 020-open.py > | 021-close.py > | 200-write.py > | python: hivex-py.c:52: get_handle: Assertion `obj' failed. > `---- > > I narrowed this down to hivex-py.c:py_hivex_node_add_child(): > > The call > > ,---- > | PyArg_ParseTuple (args, (char *) "OLs:hivex_node_add_child", > | &py_h, &parent, &name) > `---- > > results in `py_h' set to NULL, though Python's documentation claims that > this cannot happen. I think this happens because `parent' is declared a > `long int', but "L" in the format string corresponds to a `long long'. > On amd64, they have the same size, but on i386 they don't, so the > PyObject pointer is written to the wrong address. > > Please consider applying the patch below which just changes the format > string. After regenerating hivex-py.c, I have successfully tested the > 1.2.5 code base on both architectures. > > Cheers, > -Hilko > > diff --git a/generator/generator.ml b/generator/generator.ml > index 7e706d1..9722312 100755 > --- a/generator/generator.ml > +++ b/generator/generator.ml > @@ -2875,7 +2875,7 @@ put_val_type (char *val, size_t len, hive_type t) > pr "O" > | ANode n > | AValue n -> > - pr "L" > + pr "l" > | AString n -> > pr "s" > | AStringNullable n ->Looking at the code, I think this was clearly a mistake and I've pushed your fix. Thanks for your contribution! Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
Maybe Matching Threads
- [hivex] Segfault for an integer value to node_set_value
- [hivex] [PATCH 0/6] Python fixes for node_set_value
- [PATCH] hivex: add hivex_set_value api call and ocaml/perl bindings, tests
- [PATCH 1/2] Add type checking, support integers as value
- hivex: Make node names and value names with embedded null characters accessible