Re: bug in sorting?

Jaap Vermeulen (jaap@sequent.com)
Fri, 06 Aug 1993 12:39:18 -0700

| The following little program causes my python to core dump with a bus
| error. Could others try it and see if it does the same? As far as I
| can see, the objects passed to the compare function are corrupted in
| some way and the first operation on either one causes a crash. It
| doesn't do it with 0.9.8. I've had a brief browse with my debugger but
| without much luck.

After staring at it a little, I figured it out. It should be passing
(object *) to mkvalue(), not (object **) in listobject.c:cmp().
Here's the patch:

*** listobject.c.Save Thu Jul 29 01:25:08 1993
--- listobject.c Fri Aug 6 12:33:24 1993
***************
*** 520,526
return cmpobject(* (object **) v, * (object **) w);

/* Call the user-supplied comparison function */
! t = mkvalue("OO", v, w);
if (t == NULL)
return 0;
res = call_object(cmpfunc, t);

--- 520,526 -----
return cmpobject(* (object **) v, * (object **) w);

/* Call the user-supplied comparison function */
! t = mkvalue("OO", * (object **) v, * (object **) w);
if (t == NULL)
return 0;
res = call_object(cmpfunc, t);

Have fun,

-Jaap-