[PATCH] malloc_conf_init: revert errno value when readlink(2) fail.

Alex alex at kaworu.ch
Fri Sep 20 11:47:26 PDT 2013


Hi,

In malloc_conf_init(), readlink(2) is called in order to read 
"/etc/malloc.conf". When readlink(2) fail (which is a common case, for 
exemple when "/etc/malloc.conf" does not exists) errno is set. This can 
lead to unexpected behaviour of malloc(), in my case malloc() set 
errno=2 (ENOENT) because "/etc/malloc.conf" does not exist (see test.c 
attached).

I wrote a patch that fixed the issue (against the dev branch). At first 
I didn't catch the !_WIN32 condition, so review is welcome (I could not 
test it under Windows). Also I thought it might be better to save & 
restore errno in malloc_init(), because it could catch other function 
call modifying errno. Does this make sens ?

Patch attached :)

Regards,
Alex.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-malloc_conf_init-revert-errno-value-when-readlink-2-.patch
Type: text/x-patch
Size: 1465 bytes
Desc: not available
URL: <http://jemalloc.net/mailman/jemalloc-discuss/attachments/20130920/887e7139/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-csrc
Size: 267 bytes
Desc: not available
URL: <http://jemalloc.net/mailman/jemalloc-discuss/attachments/20130920/887e7139/attachment.c>


More information about the jemalloc-discuss mailing list