[Python-bugs-list] [ python-Bugs-640557 ] '64-bit' systems and the dbm module

noreply@sourceforge.net noreply@sourceforge.net
Fri, 22 Nov 2002 10:00:44 -0800


Bugs item #640557, was opened at 2002-11-19 09:10
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=640557&group_id=5470

Category: Extension Modules
Group: Python 2.2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Nick Maclaren (nmm1)
>Assigned to: Neal Norwitz (nnorwitz)
Summary: '64-bit' systems and the dbm module

Initial Comment:
Modules/dbmmodule.c is broken on systems where long is
longer than int.
The cause is that convertsimple in Python/getargs.c
writes a length
(the '#' format descriptor) into an int, but the dsize
field of a datum
type is a long.  I have no fix, I am afraid.

The symptom on Solaris 9 with -xarch=v9b is SIGSEGV,
due to a huge
and bogus size.


----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2002-11-22 19:00

Message:
Logged In: YES 
user_id=21627

The patch is clearly correct, and it looks like it could
solve this problem. Please apply it.

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-11-22 15:43

Message:
Logged In: YES 
user_id=33168

Martin, could you review the patch?  It's pretty
straightforward.

----------------------------------------------------------------------

Comment By: Nick Maclaren (nmm1)
Date: 2002-11-21 13:10

Message:
Logged In: YES 
user_id=652073

The fix compiles and tests cleanly.


----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-11-21 00:33

Message:
Logged In: YES 
user_id=33168

Me neither!  I just hate bugs, especially ones that crash. 
I've added the updated file here.  It is for 2.2.2.  Can you
download the file, replace the old Modules/dbmmodule.c,
recompile, and test.  This works for me.

----------------------------------------------------------------------

Comment By: Nick Maclaren (nmm1)
Date: 2002-11-21 00:15

Message:
Logged In: YES 
user_id=652073

Yes, I can test it.  I am also happy to run a more thorough
test than the default, if you send me one and it doesn't
involve a lot of hassle.  But I am not personally very
interested in this, as I have never used dbm in my life!

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-11-20 23:58

Message:
Logged In: YES 
user_id=33168

It looks like this is all over the place in dbmmodule. 
Couldn't you use a local variable, instead of dsize, like below?

Instead of this:
  if (!PyArg_Parse(key, "s#", &krec.dptr, &krec.dsize) )

do this:
  int tmp_size;
  if (!PyArg_Parse(key, "s#", &krec.dptr, &tmp_size) )  {}
  krec.dsize = tmp_size;
Nick, can you test this?  If you need me to, I can produce a
patch if you can test.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=640557&group_id=5470