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

Running shards works for root, not for normal user #6965

Closed
rodti opened this issue Oct 19, 2018 · 11 comments
Closed

Running shards works for root, not for normal user #6965

rodti opened this issue Oct 19, 2018 · 11 comments

Comments

@rodti
Copy link

rodti commented Oct 19, 2018

Clean install of Crystal (via aptitude) on Debian 9, running in a Proxmox LXC container.

Running shards as root gives expected results:

Missing shard.yml. Please run 'shards init'

Running shards for any other normal user account (without sudo) crashes:

Failed to raise an exception: END_OF_STACK
[0x7f70dc3d6826] ???
[0x7f70dc37a8a3] ???
[0x7f70dc37b4b8] ???
[0x7f70dc37d6d3] ???
[0x7f70dc39e8c2] ???
[0x7f70dc37c8fd] ???
[0x7f70dc6239a5] ???

I also get a crash running crystal as a normal user. I've tried this with several new user accounts, all have the same issue.

Also, out of abundance of caution, I've tried this on both unprivileged and privileged LXC containers, with identical results.

@refi64
Copy link
Contributor

refi64 commented Oct 19, 2018

I've also noticed this under rootless podman containers.

@j8r
Copy link
Contributor

j8r commented Oct 21, 2018

This issue isn't related to Crystal itself, but the shards package manager. Please open the issue in this project: https://github.com/crystal-lang/crystal/shards

@straight-shoota
Copy link
Member

I also get a crash running crystal as a normal user.

Doesn't look like it's specific to shards.

And Failed to raise an exception: END_OF_STACK doesn't either.

@ysbaddaden
Copy link
Contributor

I use LXC containers everyday, and never had such an issue. I would easily blame systemd, maybe.

@j8r
Copy link
Contributor

j8r commented Oct 21, 2018

@rodti are you sure you have read/write permissions on the directories used by shards?
I got this as a normal user in /srv:

Unhandled exception: Error opening file '/srv/shard.yml' with mode 'w': Permission denied (Errno)
Failed to raise an exception: END_OF_STACK
[0x557996f25c56] *CallStack::print_backtrace:Int32 +118
[0x557996f08b46] __crystal_raise +86
[0x557996f090ee] *raise<Errno>:NoReturn +206
[0x557996f5b3d9] *Crystal::System::File::open<String, String, File::Permissions>:Int32 +201
[0x557996f50a0d] *File::new<String, String, File::Permissions, Nil, Nil>:File +45
[0x557996f1d3dd] *CallStack::read_dwarf_sections:(Array(Tuple(UInt64, UInt64, String)) | Nil) +109
[0x557996f1d11d] *CallStack::decode_line_number<UInt64>:Tuple(String | Nil, Int32, Int32) +45
[0x557996f1c8c8] *CallStack#decode_backtrace:Array(String) +296
[0x557996f1c782] *CallStack#printable_backtrace:Array(String)+ +50
[0x557996f5063d] *Exception+ +77
[0x557996f50088] *Exception+ +120
[0x557996fa0978] *AtExitHandlers::run<Int32>:Int32 +488
[0x557996f85654] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +148
[0x557996f13816] main +6
[0x7f2aaa8ccad6] __libc_start_main +54

I got this by compiling shards statically with crystal build --static --link-flags -lunwind src/shards.cr:

Failed to raise an exception: END_OF_STACK
[0x0] ???

@rodti
Copy link
Author

rodti commented Oct 22, 2018

Hi everyone, apologies for the delay in replying.

I've created a brand new LXC container on a different Proxmox (pve 5.2-2) host. This uses a Debian 9.3.1 image.

I've run apt-get dist-upgrade to ensure everything's up to date, added apt-transport-https, then followed the instructions for Debian/Ubuntu to add Crystal's aptitude source. I've install using apt install crystal which completes successfully with all dependencies.

I then ran adduser test to create a 'test' user.

Running crystal as root in /root gives:

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

Command:
    init                     generate a new project
    build                    build an executable
    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

Running shards as root in /root gives:

Missing shard.yml. Please run 'shards init'

Running crystal as test in /home/test gives:

Failed to raise an exception: END_OF_STACK
[0x7fed6d889746] ???
[0x7fed6cf82349] ???
[0x7fed6cf83488] ???
[0x7fed6cf882a3] ???
[0x7fed6cfbb3f6] ???
[0x7fed6cf8679d] ???
[0x7fed6ecc8dfe] ???

Running shards as test in /home/test gives:

Failed to raise an exception: END_OF_STACK
[0x7f6f4dd6e826] ???
[0x7f6f4dd128a3] ???
[0x7f6f4dd134b8] ???
[0x7f6f4dd156d3] ???
[0x7f6f4dd368c2] ???
[0x7f6f4dd148fd] ???
[0x7f6f4dfbb9a5] ???

Happy to share any logs if required.

@ysbaddaden
Copy link
Contributor

Your container is restricting access to something that Crystal depends on (e.g. a file from /dev or proc).

You can use strace crystal to understand where it's failing. For example, these paths will be open by crystal or a dependency (bdwgc, libevent, ...):

  • /dev/zero
  • /proc/stat
  • /dev/pts/...
  • /proc/self/fd/...
  • /dev/urandom

@rodti
Copy link
Author

rodti commented Oct 22, 2018

Your container is restricting access to something that Crystal depends on (e.g. a file from /dev or proc).

Thanks for the tip. I've run strace and it was failing on /dev/tty1 access. I've changed the permissions on /dev/tty1 to a fairly loose 777 and it now works correctly.

Odd that it needs a workaround though!

@ysbaddaden
Copy link
Contributor

Related to #6518

@rodti
Copy link
Author

rodti commented Oct 22, 2018

When I went to apply the fix to the container where I noticed this issue it was /dev/pts3 rather than /dev/tty1, but adding the user to group tty and setting permissions to 660 worked. I'm assuming this is a peculiarity of LXC and not Crystal, so will close this issue.

@rodti rodti closed this as completed Oct 22, 2018
@RX14
Copy link
Contributor

RX14 commented Oct 22, 2018

Duplicate of #6624

Fixed by #6660 most likely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants