localeconv() and setlocale() thread-safety
От | Heikki Linnakangas |
---|---|
Тема | localeconv() and setlocale() thread-safety |
Дата | |
Msg-id | 540755E1.50700@vmware.com обсуждение исходный текст |
Список | pgsql-odbc |
convert.c has a mechanism to convert the decimal separator in numeric strings between '.' and the separator of the current locale (e.g. ',' in Finnish). The implementation is not thread-safe. If you switch the locale in an application, and then run a query in two threads concurrently, and they both call current_numeric_locale() at the same time, they might both try to free the old current_locale string, causing a crash. That might seem unlikely to happen in practice, but I just received a stack trace from a crash dump from a testing environment that contained words "psqlodbc", "lconv", and "free". The stack trace was missing/had garbled symbols, so I couldn't make more sense of it, but current_numeric_locale() is the only place in psqlodbc that deals with lconv structs. The crash may well have been something completely unrelated, but this seems worth fixing anyway. There are more issues that we can't do much about, if an application changes the locale in one thread, while another thread is running a query. In that situation, the decimal separator we got from localeconv() might not match the decimal separator that our earlier call to sprintf() used. But as I said, there isn't much we can do about that, since there is no thread-safe version of localeconv(). I'll commit the attached patch that fixes the first problem, unless someone has a better idea. PS. Does anyone know an example of a locale that uses a multi-byte character as the decimal separator? - Heikki
Вложения
В списке pgsql-odbc по дате отправления: