[reportlab-users] Chasing pyHnj error

Robin Becker robin at reportlab.com
Sun Nov 25 06:22:54 EST 2007


Dinu Gherman wrote:
........

>

> Thanks for the effort! Testing this on my Mac Book Pro, now running

> Mac OS 10.4.11 shows this funny unchanged behviour below. Seems like

> I don't even need to specify a hyphenation file, BTW...

>

> Regards,

>

> Dinu

>

>


The default filename is "/usr/local/share/pyHnj/hyphen.mashed" so if
that file exists the pyHnj.Hyphen() call will work OK.




> Python 2.5.1 (r251:54863, Oct 5 2007, 13:55:04)

> [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin

> Type "help", "copyright", "credits" or "license" for more information.

> >>>

> >>> import pyHnj

> >>> pyHnj.__file__

> '/usr/local/lib/python2.5/site-packages/pyHnj.so'

> >>> h = pyHnj.Hyphen("hyphen.mashed")

> >>> h.hyphenate("hyphenation")

> 'hy-phen-ation'

> >>> h = pyHnj.Hyphen("hyphen.mashed")

> python2.5(427) malloc: *** Deallocation of a pointer not malloced:

> 0x5450b0; This could be a double free(), or free() called with the

> middle of an allocated block; Try setting environment variable

> MallocHelp to see tools to help debug

> >>> h.hyphenate("hyphenation")

> 'hy-phen-ation'

> >>>

> >>> ^D

> python2.5(427) malloc: *** Deallocation of a pointer not malloced:

> 0x5450a0; This could be a double free(), or free() called with the

> middle of an allocated block; Try setting environment variable

> MallocHelp to see tools to help debug

.....

the error is almost certainly caused by the dealloc of the Hyphen
object. That routine looks like

static void
Hyphen_dealloc(Hyphenobject *self) {
if (self->hdict != NULL) {
hnj_hyphen_free(self->hdict);
self->hdict = NULL;
}
PyMem_DEL(self);
}


Try the script

import pyHnj
print pyHnj.__file__
h = pyHnj.Hyphen("hyphen.mashed")
del h

if that errors then it's almost certainly just the allocate/deallocate.

I notice that we're using PyObject_NEW as allocation and PyMem_DEL as
deallocate. I'm almost sure that's wrong; I'm just not seeing the error.
I checked in a change to use the PyObject_DEL in place of PyMem_DEL. Can
you give that a try?
--
Robin Becker


More information about the reportlab-users mailing list