Re: jemalloc_rtree failed assertion error

From: Enji Cooper <yaneurabeya_at_gmail.com>
Date: Mon, 08 Jan 2024 17:36:37 UTC
> On Jan 8, 2024, at 09:34, Enji Cooper <yaneurabeya@gmail.com> wrote:
> 
> 
> 
>>> On Jan 6, 2024, at 14:48, Farhan Khan <farhan@farhan.codes> wrote:
>>> 
>> Hi all,
>> 
>> I am writing some code on FreeBSD 15.0-CURRENT and getting this error that I do not understand:
>> 
>> <jemalloc>: jemalloc_rtree.c:205: Failed assertion: "!dependent || leaf != NULL"
>> 
>> In this case, it happens during a realloc() call. This may very well be a bug in my code, but the message is unclear to me. I found the section the section in the code (/usr/src/contrib/jemalloc/src/rtree.c) but without thoroughly diving into the malloc() call I do not understand it. The jemalloc(3) man page has a section called "DIAGNOSTIC MESSAGES", but it does not offer many details.
>> 
>> What does this error mean?
>> 
>> As an aside, I recommend that this is either documented in more detail because I found several people citing the problem but I did not find an explanation.
> 
> Hi Farhan!
> 
> I would reach out to the author, Justin Evans about potential improvements in terms of the diagnostic message via the jemalloc project GitHub issue tracker.
> 
> Also, taking a stab based on closed issues, it might be that the memory being reallocated is not being managed via jemalloc: https://github.com/jemalloc/jemalloc/issues/2500 . If the memory is being managed via some custom malloc code not in libc/jemalloc (a prime example being python’s default memory arena allocator) or is stack memory, the memory will need to be copied to an address managed via jemalloc using callow/memcpy/etc.

This should read “calloc” (pesky autocorrect got it wrong).

> 
> Best of luck!
> -Enji