Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eventloop initialization failure - Failed to open input method #636

Closed
moragtong opened this issue Aug 23, 2018 · 11 comments · Fixed by #1445
Closed

Eventloop initialization failure - Failed to open input method #636

moragtong opened this issue Aug 23, 2018 · 11 comments · Fixed by #1445
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - x11 H - good first issue Ideal for new contributors P - high Vital to have

Comments

@moragtong
Copy link

moragtong commented Aug 23, 2018

Got this on Debian Buster.

thread 'main' panicked at 'Failed to open input method: PotentialInputMethods {
    xmodifiers: None,
    fallbacks: [
        PotentialInputMethod {
            name: "@im=local",
            successful: Some(
                false
            )
        },
        PotentialInputMethod {
            name: "@im=",
            successful: Some(
                false
            )
        }
    ],
    _xim_servers: Err(
        GetPropertyError(
            TypeMismatch(
                0
            )
        )
    )
}', /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.17.2/src/platform/linux/x11/mod.rs:85:17

Managed to fix it by commenting line 81 (setlocale) in the file mentioned in the log.

Edit: It seems that setting the LC_CTYPE locale to an empty c string is invalid, using b"C\0" worked.
Using LC_ALL doesn't work either with an empty string, at least on my system.

Update: It seems that the problem has something to do with my etc/default/locale being set to en_IL.UTF-8. I changed it to en_US.UTF-8 and it worked.

@francesca64 francesca64 added B - bug Dang, that shouldn't have happened DS - x11 C - needs investigation Issue must be confirmed and researched labels Aug 23, 2018
@elichai
Copy link

elichai commented May 23, 2019

Same here. changing from LANG=en_IL.UTF-8 to LANG=en_US.UTF-8 fixes this error:

thread 'main' panicked at 'Failed to open input method: PotentialInputMethods {
    xmodifiers: None,
    fallbacks: [
        PotentialInputMethod {
            name: "@im=local",
            successful: Some(
                false
            )
        },
        PotentialInputMethod {
            name: "@im=",
            successful: Some(
                false
            )
        }
    ],
    _xim_servers: Err(
        GetPropertyError(
            TypeMismatch(
                0
            )
        )
    )
}', /build/alacritty-eHHw83/alacritty-0.3.2~1556145865~18.04~4ba1771/vendor/winit/src/platform/linux/x11/mod.rs:92:17
note: Run with `RUST_BACKTRACE=1` for a backtrace.

@Grissess
Copy link

Same thing here; encountered within alacritty as above. My default LANG is en_US.utf8@grissess (mostly en_US plus ISO8601 datetime), which resulted in exactly the error above. Using LANG=en_US.utf8 fixes it.

The alacritty issue ref'd above has other people changing locales and getting it working, too. Is there any way to work around this without changing LANG?

@goddessfreya goddessfreya added the P - high Vital to have label May 26, 2019
@goddessfreya
Copy link
Contributor

I'd love to investigate this, but I cannot reproduce it.

Tried adding en_IL.UTF-8 to my /etc/local.gen, rebuilding my locals with local-gen, then changing my default to en_IL.UTF-8 in /etc/local.conf, then unset LANG, then source /etc/profile.d/locale.sh, to no avail.

@elichai
Copy link

elichai commented May 26, 2019

Run echo $LANG before you run to make sure that the lang is really the IL one.

Btw you can just export it and it should also do the trick.

@Grissess
Copy link

Even if you're having trouble reproducing it there, I'll gladly proffer my system for test builds and theories as needed.

(To follow up what elichai said, I just did the cross-LANG test with LANG=en_US.utf8 alacritty verbatim.)

@goddessfreya
Copy link
Contributor

goddessfreya commented May 26, 2019

https://i.imgur.com/i61KD4I.png :/

It would be useful to know the values of inner and input_method on successful runs, and on failed runs.
https://github.com/rust-windowing/winit/blob/master/src/platform/linux/x11/ime/mod.rs#L60

The values of local_modifiers and im would also be of interest: https://github.com/rust-windowing/winit/blob/master/src/platform/linux/x11/ime/input_method.rs#L20

So would printing out input_method above these two places: https://github.com/rust-windowing/winit/blob/master/src/platform/linux/x11/ime/input_method.rs#L264 https://github.com/rust-windowing/winit/blob/master/src/platform/linux/x11/ime/input_method.rs#L274

EDIT:
I'm available 6pm-10pm Tues to Friday UTC-6 on #Glutin:matrix.org, if any of you want to work this issue out together.

@EpicatSupercell
Copy link

EpicatSupercell commented Feb 5, 2020

Using version 0.19.5
Failed run (using en_IL.utf8):

src/platform/linux/x11/ime/input_method.rs:274 input_method: PotentialInputMethod { name: "@im=local", successful: None }
src/platform/linux/x11/ime/input_method.rs:20 locale_modifiers: "@im=local"
src/platform/linux/x11/ime/input_method.rs:26 XSetLocaleModifiers: 0x0
src/platform/linux/x11/ime/input_method.rs:34 im: 0x0
src/platform/linux/x11/ime/input_method.rs:274 input_method: PotentialInputMethod { name: "@im=", successful: None }
src/platform/linux/x11/ime/input_method.rs:20 locale_modifiers: "@im="
src/platform/linux/x11/ime/input_method.rs:26 XSetLocaleModifiers: 0x0
src/platform/linux/x11/ime/input_method.rs:34 im: 0x0
src/platform/linux/x11/ime/mod.rs:60 input_method: Failure
src/platform/linux/x11/ime/mod.rs:60 inner: ImeInner { xconn: 0x55834ba884d0, im: 0x0, potential_input_methods: PotentialInputMethods { xmodifiers: None, fallbacks: [PotentialInputMethod { name: "@im=local", successful: Some(false) }, PotentialInputMethod { name: "@im=", successful: Some(false) }], _xim_servers: Err(GetPropertyError(TypeMismatch(0))) }, contexts: {}, destroy_callback: XIMCallback { client_data: 0x55834baa0290, callback: Some(0x55834acbee80) }, is_destroyed: false, is_fallback: false }

Successful run (using en_US.utf8):

src/platform/linux/x11/ime/input_method.rs:274 input_method: PotentialInputMethod { name: "@im=local", successful: None }
src/platform/linux/x11/ime/input_method.rs:20 locale_modifiers: "@im=local"
src/platform/linux/x11/ime/input_method.rs:26 XSetLocaleModifiers: 0x557ccb507280
src/platform/linux/x11/ime/input_method.rs:34 im: 0x557ccb5072a0
src/platform/linux/x11/ime/mod.rs:60 input_method: Fallback(InputMethod { im: 0x557ccb5072a0, name: "@im=local" })
src/platform/linux/x11/ime/mod.rs:60 inner: ImeInner { xconn: 0x557ccb4c44d0, im: 0x0, potential_input_methods: PotentialInputMethods { xmodifiers: None, fallbacks: [PotentialInputMethod { name: "@im=local", successful: Some(true) }, PotentialInputMethod { name: "@im=", successful: None }], _xim_servers: Err(GetPropertyError(TypeMismatch(0))) }, contexts: {}, destroy_callback: XIMCallback { client_data: 0x557ccb4dc490, callback: Some(0x557cc9a0be80) }, is_destroyed: false, is_fallback: false }

@goddessfreya
Copy link
Contributor

Can you test against winit master?

@EpicatSupercell
Copy link

EpicatSupercell commented Feb 9, 2020

Same with master (on February 9, 2020)
Failed run (using en_IL.utf8)

src/platform_impl/linux/x11/ime/input_method.rs:268 input_method: PotentialInputMethod { name: "@im=local", successful: None }
src/platform_impl/linux/x11/ime/input_method.rs:18 locale_modifiers: "@im=local"
src/platform_impl/linux/x11/ime/input_method.rs:25 XSetLocaleModifiers: 0x0
src/platform_impl/linux/x11/ime/input_method.rs:27 im: 0x0
src/platform_impl/linux/x11/ime/input_method.rs:268 input_method: PotentialInputMethod { name: "@im=", successful: None }
src/platform_impl/linux/x11/ime/input_method.rs:18 locale_modifiers: "@im="
src/platform_impl/linux/x11/ime/input_method.rs:25 XSetLocaleModifiers: 0x0
src/platform_impl/linux/x11/ime/input_method.rs:27 im: 0x0
src/platform_impl/linux/x11/ime/mod.rs:65 input_method: Failure
src/platform_impl/linux/x11/ime/mod.rs:65 inner: ImeInner { xconn: 0x56288127e090, im: 0x0, potential_input_methods: PotentialInputMethods { xmodifiers: None, fallbacks: [PotentialInputMethod { name: "@im=local", successful: Some(false) }, PotentialInputMethod { name: "@im=", successful: Some(false) }], _xim_servers: Err(GetPropertyError(TypeMismatch(0))) }, contexts: {}, destroy_callback: XIMCallback { client_data: 0x5628812963b0, callback: Some(0x56287f945540) }, is_destroyed: false, is_fallback: false }

Successful run (using en_US.utf8)

src/platform_impl/linux/x11/ime/input_method.rs:268 input_method: PotentialInputMethod { name: "@im=local", successful: None }
src/platform_impl/linux/x11/ime/input_method.rs:18 locale_modifiers: "@im=local"
src/platform_impl/linux/x11/ime/input_method.rs:25 XSetLocaleModifiers: 0x55cfb734f5f0
src/platform_impl/linux/x11/ime/input_method.rs:27 im: 0x55cfb734f610
src/platform_impl/linux/x11/ime/mod.rs:65 input_method: Fallback(InputMethod { im: 0x55cfb734f610, name: "@im=local" })
src/platform_impl/linux/x11/ime/mod.rs:65 inner: ImeInner { xconn: 0x55cfb730c090, im: 0x0, potential_input_methods: PotentialInputMethods { xmodifiers: None, fallbacks: [PotentialInputMethod { name: "@im=local", successful: Some(true) }, PotentialInputMethod { name: "@im=", successful: None }], _xim_servers: Err(GetPropertyError(TypeMismatch(0))) }, contexts: {}, destroy_callback: XIMCallback { client_data: 0x55cfb73242f0, callback: Some(0x55cfb6e6c540) }, is_destroyed: false, is_fallback: false }

gentooboontoo added a commit to gentooboontoo/winit that referenced this issue Feb 9, 2020
This restores default portable 'C' locale when target locale is unsupported
by X11 backend (Xlib).

When target locale is unsupported by X11, some locale-dependent Xlib
functions like `XSetLocaleModifiers` fail or have no effect triggering
later failures and panics.

When target locale is not valid, `setLocale` should normally leave the
locale unchanged (`setLocale` returns 'C'). However, in some situations,
locale is accepted by `setLocale` (`setLocale` returns the new locale)
but the accepted locale is unsupported by Xlib (`XSupportsLocale` returns
`false`).

Fix rust-windowing#636
@gentooboontoo
Copy link
Contributor

As far as I understand, it seems the initialization is failing (at least on my system) because my current locale (C.utf8) is accepted by setLocale:

setlocale(LC_CTYPE, b"\0".as_ptr() as *const _);
)
but is refused by X11 (XSetLocaleModifiers returns NULL):
(xconn.xlib.XSetLocaleModifiers)(locale_modifiers.as_ptr());

If I set my locale with LANG=C.UTF-8, the problem disappears for a reason unknown to me.

I have made a PR (#1445) which does not fix the root problem (setLocale / X11 discrepancy) but which prevents winit initialization from failing with an "invalid" locale (more details in the PR).

goddessfreya pushed a commit that referenced this issue Feb 10, 2020
This restores default portable 'C' locale when target locale is unsupported
by X11 backend (Xlib).

When target locale is unsupported by X11, some locale-dependent Xlib
functions like `XSetLocaleModifiers` fail or have no effect triggering
later failures and panics.

When target locale is not valid, `setLocale` should normally leave the
locale unchanged (`setLocale` returns 'C'). However, in some situations,
locale is accepted by `setLocale` (`setLocale` returns the new locale)
but the accepted locale is unsupported by Xlib (`XSupportsLocale` returns
`false`).

Fix #636
@sshaikh
Copy link

sshaikh commented May 19, 2021

Arrived here via alacritty: alacritty/alacritty#5153

Setting LANG doesn't appear to work for me.

EDIT: I fixed this by reverting some custom pacman config (Arch). See above issue for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - x11 H - good first issue Ideal for new contributors P - high Vital to have
Development

Successfully merging a pull request may close this issue.

8 participants