cicku / libproxy

Automatically exported from code.google.com/p/libproxy
GNU Lesser General Public License v2.1
1 stars 0 forks source link

Make get_default_port() threadsafe #196

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I see a lot of crashes in code that uses libproxy (specifically, any 
webkitgtk browser) with backtraces leading to getservbyname().

What version of the product are you using? On what operating system?

0.4.11 on OpenBSD

Please provide any additional information below.

getservbyname() is non-reentrant and should not be called by multiple threads 
unless it is locked/unlocked before and after calling.  This is a rudimentary 
fix for platforms using pthreads, but Windows is still broken.

I also don't speak cmake so that bit of getting url.cpp.o to link against 
pthread could probably use some improvement.

Original issue reported on code.google.com by joshrick...@gmail.com on 5 Jun 2013 at 6:34

GoogleCodeExporter commented 8 years ago
Another possible fix would be to use getservbyname_r, which is reentrant, but 
is non-standard and is not guaranteed to be available on all platforms.

Original comment by joshrick...@gmail.com on 5 Jun 2013 at 6:35

GoogleCodeExporter commented 8 years ago
Previous patch was incorrect as we still had a pointer to static memory which 
could be overwritten by another thread.

Original comment by joshrick...@gmail.com on 5 Jun 2013 at 7:08

Attachments: