cacalabs / libcaca

đź’© Colour ASCII Art Library
Do What The F*ck You Want To Public License
540 stars 71 forks source link

Setting the locale interferes with mpv #12

Closed sotlampr closed 8 years ago

sotlampr commented 8 years ago

Hello,

I noticed a bug when running mps-youtube with mpv on some occasions libcaca crashes mpv.

The source of the problem is that libcaca uses the setlocale function (here and here), and in languages that have comma as decimal mark this can lead to abnormal behavior. The issue was also discussed here. Can you take a look at this? S.

samhocevar commented 8 years ago

This is a bug in mpv but I’ll try to ensure libcaca restores the locale when it no longer needs it, so as to avoid the crash.

ghost commented 8 years ago

This is a bug in mpv

This is false.

but I’ll try to ensure libcaca restores the locale when it no longer needs it

This is pointless.

samhocevar commented 8 years ago

but I’ll try to ensure libcaca restores the locale when it no longer needs it

This is pointless.

I do what I want and I get to decide whether it’s worth it. Enjoy not being a fun person! ♡

ghost commented 8 years ago

It's still pointless in a very technical way. Just because you switch temporarily, it doesn't mean that

  1. another thread has called setlocale and ruined everything for you
  2. another thread is using basic C string processing and gets everything ruined by your temporary setlocale call

Both of these could be race conditions quite awesome to debug

I'm sorry that you have to learn that your loved setlocal is INSANE.

samhocevar commented 8 years ago

You either misread or misunderstood, but that’s okay, I will do fine without your help, but thanks for trying! You can still reflect on your life and remember that you are the one using libcaca and lecturing me about “pointless”.

ghost commented 8 years ago

I might have misunderstood, but you're not clarifying anything, and I don't see to what else your plan to restore the locale was related to. Anyway, you show complete lack of understanding regarding library safety issues, and you're not showing any signs of trying (or even wanting) to understand them, so I guess I can't help you.

samhocevar commented 8 years ago

Excuse me, I didn’t see where you asked for clarification. I’ve only seen you claim my plans were pointless (without knowing the details), claim that I was going to do a temporary setlocale call (I won’t, I’ll be using uselocale, which didn’t exist when I wrote libcaca), claim that I love setlocale (I don’t, but it—or a similar scheme—is required for ncurses and Xlib to properly output some Unicode glyphs). I’m fixing my code. In the meantime, you can fix your attitude.

ghost commented 8 years ago

Alright. Sorry for extrapolating (edit: and assuming) the worst implementation choice that could have taken.

ghost commented 8 years ago

I'm no sure why you need locale for X11, but newer xlib versions have UTF-8 functions. (And then there's XCB.)