Web lists-archives.com

Re: [glib] malloc and bdwgc




Yes, but glib is the only one I'm using now.

Still I don't know how to make GC_malloc() call the original malloc()
if I'm using LD_PRELOAD or the wrapper function and dlsym way.

Just now I found I've misread
http://www.gnu.org/software/libc/manual/html_node/Hooks-for-Malloc.html
, and that such replacement can possibly be done in a single-threaded
environment, because the hook is done with a global function pointer
variable initialization and it seems that the function is called
before memory allocation initialization

However as in http://stackoverflow.com/questions/4184280/are-the-gcc-memory-hooks-sometimes-bypassed
, there are nasty race conditions for such hook. And my program needs
threads.

Are there any other way around?
--
张海
浙江大学 计算机科学与技术
Blog: http://blog.zhanghai.me/
Github: https://github.com/DreaminginCodeZH


2016-01-07 19:08 GMT+08:00 Paul Davis <paul@xxxxxxxxxxxxxxxxxxxxx>:
> There are many libraries that can call malloc before main().
>
> On Thu, Jan 7, 2016 at 2:10 AM, 张海 <dreaming.in.code.zh@xxxxxxxxx> wrote:
>>
>> I'm using glib without the whole GObject system and reference counting
>> mechanism, and I'd like to integrate bdwgc
>> (https://github.com/ivmai/bdwgc/) because of the complexity of my
>> program.
>>
>> I've read about using GMemVTable to redirect memory allocation of glib
>> to GC_malloc, however as in
>> https://mail.gnome.org/archives/commits-list/2015-July/msg05892.html ,
>> such mechanism no longer works, and even more unfortunately it says
>> glib allocates memory before main() so it seems that I'm even unable
>> to hook to malloc in time as in
>> http://www.gnu.org/software/libc/manual/html_node/Hooks-for-Malloc.html
>> .
>>
>> Can I use bdwgc with glib >= 2.4.6? If so, how can I achieve that
>> correctly?
>> _______________________________________________
>> gtk-devel-list mailing list
>> gtk-devel-list@xxxxxxxxx
>> https://mail.gnome.org/mailman/listinfo/gtk-devel-list
>
>
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-devel-list