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

Error deleting file *.lock #8

Closed
NIFR91 opened this issue Oct 17, 2019 · 3 comments
Closed

Error deleting file *.lock #8

NIFR91 opened this issue Oct 17, 2019 · 3 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@NIFR91
Copy link

NIFR91 commented Oct 17, 2019

Description

I want to process some text stream with my program (the same program) as in :

echo "hello\nworld\n" | ./myprog.cr  process-lines | ./myprog.cr  process-columns

When using the crystal compiler like in #! usr/bin/env crystal I got an error so following a issue
I found crun. From the description I think it should handle my case but when using it
I found the following error :

Unhandled exception: Error deleting file '/home/ nieto/.cache/crun/writter.crystal.lock': No such file or directory (Errno)
Failed to raise an exception: END_OF_STACK
[0x55c92d246da6] ???
[0x55c92d201afb] __crystal_raise +43
[0x55c92d202af5] ???
[0x55c92d20b131] ???
[0x55c92d2067ac] ???
[0x55c92d205bff] ???
[0x55c92d21f46d] ???
[0x55c92d21d9a5] ???
[0x55c92d20429a] main +74
[0x7f8f791e309b] __libc_start_main +235
[0x55c92d20087a] _start +42
[0x0] ???
minimal program
#!/usr/bin/env crun

while line = gets 
  puts line
end 

or

#!/usr/bin/env crun 
sleep 1
@Val
Copy link
Owner

Val commented Nov 4, 2019

Like crystal-lang/crystal#8340

@Val Val added the bug Something isn't working label Nov 4, 2019
@bew
Copy link
Contributor

bew commented Nov 4, 2019

Yes @Val but iirc the lock file is generated by crun in this case, no?

@Val
Copy link
Owner

Val commented Nov 5, 2019

This issue is very interesting and reveal some race conditions

  1. File.delete(lockfile.path)
    with a possible workarround
  2. crun/src/shards.cr

    Lines 22 to 31 in 94c7c85

    File.open(shards_config_path, "w") do |file|
    file.puts <<-EOYAML
    ---
    name: #{SOURCE_FILENAME}
    version: 0.1.0
    dependencies:
    #{shards_yaml}
    ...
    EOYAML
    end
    with another possible workarround

But I added some pipe samples specifications and it still fail, see lock_deletion_race_condition_fix branch. And some times you get an error like for crystal-lang/crystal#8075 or crystal-lang/crystal#7810

> make tests
crystal tool format -i src -i spec
crun format passed
rm -f crun crun.sha256
crun clean passed
crystal build src/main.cr -o crun --warnings all --error-on-warnings --error-trace
crun build passed
crystal spec --debug --warnings all --error-on-warnings --error-trace
.....error:
Failed to raise an exception: END_OF_STACK
[0x56511fbb0e76] *CallStack::print_backtrace:Int32 +118
[0x56511fb93006] __crystal_raise +86
[0x56511fb9352e] ???
[0x56511fbe0966] *Crystal::System::File::open<String, String, File::Permissions>:Int32 +214
[0x56511fbd9c83] *File::new<String, String, File::Permissions, Nil, Nil>:File +67
[0x56511fba7b1d] *CallStack::read_dwarf_sections:(Array(Tuple(UInt64, UInt64, String)) | Nil) +109
[0x56511fba78ad] *CallStack::decode_line_number<UInt64>:Tuple(String, Int32, Int32) +45
[0x56511fba7038] *CallStack#decode_backtrace:Array(String) +296
[0x56511fba6ef2] *CallStack#printable_backtrace:Array(String) +50
[0x56511fc1560d] *Exception+ +77
[0x56511fc15458] *Exception+ +120
[0x56511fc115da] *AtExitHandlers::run<Int32>:Int32 +490
[0x56511fc514ab] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +139
[0x56511fb9da16] main +6
[0x7f988572d09b] __libc_start_main +235
[0x56511fb9188a] _start +42
[0x0] ???
Crun::BuildError: Build failed: crystal build --debug --error-on-warnings --error-trace -o /tmp/.lgmAAIcrun_spec_local_cache/foo__path_to_crystal_crun_spec_samples_pipe_echo_cr/echo.cr.crystal /path/to/crun/spec/samples/pipe/echo.cr

STDOUT:


STDERR:
In /path/to/crun/spec/samples/pipe/echo.cr:1:1

 1 | while line = gets
     ^
Error: can't find file 'prelude'

If you're trying to require a shard:
- Did you remember to run `shards install`?
- Did you make sure you're running the compiler in the same directory as your shard.yml?

@Val Val added the help wanted Extra attention is needed label Nov 5, 2019
Val added a commit that referenced this issue Apr 6, 2021
@Val Val closed this as completed in dcfd3e6 Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants