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

Invalid memory access (signal 11) at address 0x7fffdf289ff8 #6375

Closed
pcoenen opened this issue Jul 12, 2018 · 7 comments
Closed

Invalid memory access (signal 11) at address 0x7fffdf289ff8 #6375

pcoenen opened this issue Jul 12, 2018 · 7 comments

Comments

@pcoenen
Copy link

pcoenen commented Jul 12, 2018

Hello,

I got the following error while compiling my crystal code

Invalid memory access (signal 11) at address 0x7fffdf289ff8
[0x453c86] *CallStack::print_backtrace:Int32 +118
[0x44853b] __crystal_sigfault_handler +75
[0x7fcd27381390] ???
[0x4a0554] *Torrent#files:(Array(Tuple(Int32, String)) | Nil) +4
[0x4a0563] *Torrent#files:(Array(Tuple(Int32, String)) | Nil) +19 (261838 times)
[0x43b8d1] __crystal_main +1649
[0x448c76] *_crystal_main<Int32, Pointer(Pointer(UInt8))>:Nil +6
[0x4a0aa6] *Crystal::main_user_code<Int32, Pointer(Pointer(UInt8))>:Nil +6
[0x4a0962] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +50
[0x446876] main +6
[0x7fcd26940830] __libc_start_main +240
[0x43b189] _start +41
[0x0] ???

This occurs when I run the following code, the error is caused by the torrent.cr and the Torrent class
torrent.zip

require "./torrent/ctorrent_client"
require "./torrent/torrent"

client = CTorrent_Client.new
puts client.get_files("example.torrent")

torrent = Torrent.new("example.torrent")
puts torrent.files

I use version 0.24.2

@asterite
Copy link
Member

It seems client.get_files invokes itself recursively until infinity. Check the stack trace, "(261838 times)". This is just a regular stack overflow (and it's happening at runtime, not when compiling).

@asterite
Copy link
Member

I mean, Torrent#files, which is shown in the stack trace.

@ysbaddaden
Copy link
Contributor

[0x4a0563] *Torrent#files:(Array(Tuple(Int32, String)) | Nil) +19 (261838 times)

It gets repeated 261,838 times.

@ysbaddaden
Copy link
Contributor

Duplicate of #271.

@pcoenen
Copy link
Author

pcoenen commented Jul 12, 2018

Torrent.files looks like this

 def files
        if files.is_a? Nil
            client = CTorrent_Client.new
            @files = client.get_files(@path_to_torrent)
        end
        return @files
    end

@pcoenen
Copy link
Author

pcoenen commented Jul 12, 2018

How can I return the @files variable ? Without calling the files method?

@ysbaddaden
Copy link
Contributor

The problem is that you're checking files instead of @files:

def files
  @files ||= CTorrent_Client.new.get_files(@path_to_torrent)
end

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

No branches or pull requests

3 participants