473,382 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

PQueue and Python 2.5

Hello,

Recently I was looking for a Priority Queue module, and I've found
Pqueue by Andrew Snare [1]. When I use it with Python 2.4 everything
works okay, at least on the two system I've tested it on (Debian based
AMD 64) and OS PPC.

However, when I use it with Python 2.5 - again on the same machines,
exiting always gives a pointer error. The easiest to demonstrate this
is:

python2.5 -c 'from pqueue import PQueue; PQueue()'

On the Debian system:
$ python2.5 -c 'from pqueue import PQueue; PQueue()'
*** glibc detected *** free(): invalid pointer: 0x00002ad7b5720288 ***
Abort

And on my PowerBook:
python2.5(8124) malloc: *** Deallocation of a pointer not malloced:
0x3b4218; This could be a double free(), or free() called with the
middle of an allocated block;

A memory fault can also be immediately triggered by apply 'del' to a
PQueue-instance. As said, with Python 2.4 it seems to perform without
problems.

I haven't got a clue how to investigate this, but I would be willing to
help if someone has any ideas.

Berteun

[1] http://py.vaults.ca/apyllo.py/514463...44789.44776582

Jan 19 '07 #1
4 1376
"Berteun Damman" <be*****@gmail.comescribió en el mensaje
news:11**********************@51g2000cwl.googlegro ups.com...
Recently I was looking for a Priority Queue module, and I've found
Pqueue by Andrew Snare [1].
That appears to be rather ancient, from 1999. Is it a pure Python
implementation or has some C code too?

Python got in 2.3 a heapq module in its standard library; I think it is what
you want, no need for an additional module.
*** glibc detected *** free(): invalid pointer: 0x00002ad7b5720288 ***
Abort

And on my PowerBook:
python2.5(8124) malloc: *** Deallocation of a pointer not malloced:
0x3b4218; This could be a double free(), or free() called with the
middle of an allocated block;

A memory fault can also be immediately triggered by apply 'del' to a
PQueue-instance. As said, with Python 2.4 it seems to perform without
problems.
Ah! then I bet:
- There is some C code involved.
- It carelessly mixes PyMem_Malloc with PyObject_Free or similar as
described in
http://docs.python.org/whatsnew/ports.html

So do yourself a favor and forget about such old piece of code...

--
Gabriel Genellina
Jan 19 '07 #2
Berteun Damman schrieb:
I haven't got a clue how to investigate this, but I would be willing to
help if someone has any ideas.
There are a number of problems in this code; the most significant one is
the incorrect usage of memory management API. In pqueue_dealloc, the
call PyMem_DEL(pqp) should read PyObject_DEL(pqp), as the object was
allocated with PyObject_NEW. Because this was a common error once,
Python up to 2.4 detected that error and silently corrected it (at some
runtime cost); Python 2.5 now has removed this work-around.

I'll contact the author.

Regards,
Martin
Jan 20 '07 #3
On 20/01/2007 11.29, Martin v. Löwis wrote:
>I haven't got a clue how to investigate this, but I would be willing to
help if someone has any ideas.

There are a number of problems in this code; the most significant one is
the incorrect usage of memory management API. In pqueue_dealloc, the
call PyMem_DEL(pqp) should read PyObject_DEL(pqp), as the object was
allocated with PyObject_NEW. Because this was a common error once,
Python up to 2.4 detected that error and silently corrected it (at some
runtime cost); Python 2.5 now has removed this work-around.
And by the way, this is also a FAQ:

http://effbot.org/pyfaq/why-does-my-...-under-2.5.htm

and even explained in the Misc/NEWS of Python 2.5.
--
Giovanni Bajo
Jan 20 '07 #4
Gabriel Genellina wrote:
Python got in 2.3 a heapq module in its standard library; I think it is what
Ah! then I bet:
- There is some C code involved.
- It carelessly mixes PyMem_Malloc with PyObject_Free or similar as
described in
http://docs.python.org/whatsnew/ports.html

So do yourself a favor and forget about such old piece of code...
I would be happy to do so, but it does suit my needs quite well. :) But
everybody thanks for pointing out the probable cause, I never did
anything with C-extentions before, so I wasn't aware of the 2.5
changes. But I'll look into the code.

Berteun

Jan 22 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
Subsciber123
by: Subsciber123 | last post by:
I am working on a program that would make firefox accessible to locked-in patients. What I need to be able to do is from python, find all the links and buttons on the active web page. I need to be...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.