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

double free #46

Open
freeze-dolphin opened this issue Jul 27, 2022 · 0 comments
Open

double free #46

freeze-dolphin opened this issue Jul 27, 2022 · 0 comments

Comments

@freeze-dolphin
Copy link

I think this problem might be related to crsfml, so I post here as well.
Here is the original page: https://forum.crystal-lang.org/t/double-free-or-corruption-prev/4811


Recently I want to write a program to read script files like this: https://pastebin.com/nKMS14fX


I know little about C, so as the 'double free'. And I am confused.
Here is my code: (it truly takes time for me to locate the problematic function, since this error msg has no traceback...)

      
  def ArcaeaInspector.update_txt(new_text : String, line_num : Int32)
    case line_num
    when 0
      tx = @@txta
    when 1
      tx = @@txtb
    when 2
      tx = @@txtc
    end
    tx = tx.not_nil!
    tx.string = new_text
    lb = tx.local_bounds
    tx.origin = SF.vector2f lb.left + lb.width / 2, lb.top + lb.height / 2
    tx.position = SF.vector2f(
      @@window.size.x / 2,
      @@window.size.y - @@window.size.y / 5 + line_num * 20)
  end

Here is where this func is called:

  def say(content : Array(String))
      ArcaeaInspector.clear_txt
      i = -1
      content.each do |t|
        SF.sleep SF.seconds 1.5
        i += 1
        ArcaeaInspector.update_txt t, i
      end
      SF.sleep SF.seconds 1
      ArcaeaInspector.show_arrow
    end

The code is at my github repository

By the way, I've also tried run the program in release mode, and the error exists still.
What's more, this occurs "sometimes". If I'm luck enough

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

1 participant