[sr-dev] Race condition in Makefile.libs

Richard Fuchs rfuchs at sipwise.com
Sat Jan 26 00:30:24 CET 2013


Hello,

There seems to be a race condition in Makefile.libs that occurs
sporadically when doing parallel builds (make -j). I believe the culprit
part is this:



$(NAME): $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME) $(LIBINAME_F)

$(LIB_RUNTIME_NAME):
        - at ln -s $(LIB_NAME) $(LIB_RUNTIME_NAME)

$(LIB_LINK_NAME):
ifeq ($(OS), freebsd)
        - at ln -s $(LIB_RUNTIME_NAME) $(LIB_LINK_NAME)
else
        - at ln -s $(LIB_NAME) $(LIB_LINK_NAME)
endif



The problem is that dependencies (the ln -s commands) get built first,
and the actual target ($(NAME)) last. The result is that for a while,
the symlinks already exist while the lib itself is not fully built yet.
In the meantime, other make children build something else that depends
on the lib, see that the symlink already exists and hence think the
target has already been built, which then results in various funny
errors when the linker tries to read a non-existent or half-finished .so
file. At least I think that's what happens.

Unfortunately I have no idea how to fix this within the current makefile
framework. I tried reordering the dependencies (making the symlink
targets depend on the lib instead of the other way around) but those all
resulted in build failures.

cheers

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20130125/9500ecaa/attachment-0001.pgp>


More information about the sr-dev mailing list