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

http requests from macOS get a malloc error. #117

Open
tsugua opened this issue Jun 5, 2021 · 1 comment
Open

http requests from macOS get a malloc error. #117

tsugua opened this issue Jun 5, 2021 · 1 comment

Comments

@tsugua
Copy link

tsugua commented Jun 5, 2021

Here is the error we are getting when we try to make an http request using afmotion 3. Working on a reduction now to see where the issue is coming from.

Control Application(22482,0x70000f68d000) malloc: *** error for object 0x1011680e0: pointer being realloc'd was not allocated
Control Application(22482,0x70000f68d000) malloc: *** set a breakpoint in malloc_error_break to debug
@tsugua
Copy link
Author

tsugua commented Jun 5, 2021

Here's an app delegate file which shows the issues with the JSON put request. send_json and send_json_1 both crash the app with a malloc error. send_get works as expected

class AppDelegate
  def applicationDidFinishLaunching(notification)
    buildMenu
    
    # send_get
    
    #first attempt, format json in hash and send (used to work with AFMotion 2)
    json = {"on"=>true, "sat"=>128, "bri"=>254, "hue"=>10000}
    # send_json(json)
    
    #second attempt, format as per docs on home page
    send_json_1(json)
    
  end
  
  def send_get
    AFMotion::HTTP.get("http://google.com", params: { q: "rubymotion" }) do |result|
      NSLog result.body.to_s
    end
  end
  
  def send_json(json)
    NSLog "sending HTTP request now.. #{json}"
    AFMotion::JSON.put("http://localhost:5000/api/101011101001/groups/0/action", params: {on: true, sat: 128, bri: 254, hue: 10000}) do |result|
      NSLog result.body.to_s
    end
  end
  
  def send_json_1(json)
    NSLog "sending HTTP request now.. #{json}"
    AFMotion::JSON.put("http://localhost:5000/api/101011101001/groups/0/action", params: json) do |result|
      NSLog result.body.to_s
    end
  end
  
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

1 participant