Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 616256 - dev-lang/crystal-0.21.1 corrupts TTYs
Summary: dev-lang/crystal-0.21.1 corrupts TTYs
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Lixiao Chen
URL: https://github.com/crystal-lang/cryst...
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2017-04-21 23:50 UTC by Renich Bon Ciric
Modified: 2017-04-24 14:12 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
STDIO workaround patch (stdio_workaround.patch,285 bytes, patch)
2017-04-21 23:50 UTC, Renich Bon Ciric
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Renich Bon Ciric 2017-04-21 23:50:02 UTC
Created attachment 470608 [details, diff]
STDIO workaround patch

This is a known bug: https://github.com/crystal-lang/crystal/issues/2065

The problem is the following:

$ su -
password: 

# logout

$ crystal
Usage: crystal [command] [switches] [program file] [--] [arguments]

Command:
    init                     generate a new project
    build                    build an executable
    deps                     install project dependencies
    docs                     generate documentation
    env                      print Crystal environment information
    eval                     eval code from args or standard input
    play                     starts crystal playground server
    run (default)            build and run program
    spec                     build and run specs (in spec directory)
    tool                     run a tool
    help, --help, -h         show this help
    version, --version, -v   show version

$ su -
Authentication token manipulation error


I've, successfully, patched the compiler with a suggestion from RX14 @ freenode#crystal-lang.

I will attach the patch that enables a workaround

I've tested it and it works.
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2017-04-22 23:11:24 UTC
Thanks for the patch!

AFAIU your change switches stdio descriptors to blocking at program startup time
(not shutdown time).

I have no idea how crystal-lang's runtime works but I would imagine
the fix to cause occasional locks and pauses of runtime.

Typical example would be something like the following:

- two threads both block on read() from stdin at the same time
- libevent queues read calls into epoll()
- user inputs data
- both threads are unpaused by libevent and rescheduled for execution
- one of threads does read() syscall and reads out whole user output
- another thread calls read() syscall on empty STDIN and blocks the runtime

Maybe it's not too bad as it's a special corner case.

I'll apply your workaround tomorrow if there will be no change in original bug.
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2017-04-23 21:41:55 UTC
Pushed your patch as:
    https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3cf9beab238c015964bb1c8193d9a4394fce3a21

Please note it's not enabled by default and needs USE=blocking-stdio-hack:

"""
dev-lang/crystal: Workaround tty corruption in crystal, bug #616256
Patch restores blocking mode of file desriptors in exchange
of potential runtime deadlocks when dealing with stdio.

As it's a potentially invasive patch it's not enabled by default
and is available only under USE=blocking-stdio-hack
"""

Thank you!
Comment 3 Renich Bon Ciric 2017-04-24 14:12:50 UTC
Cool, man. Thanks a lot.