-
Notifications
You must be signed in to change notification settings - Fork 33
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
operations fail if arguments go out of scope #123
Comments
Hi @marcusb, |
Hello @marcusb, |
Hello @marcusb, Firstly, apologies for the delay on our part. Secondly, I see your point. Thank you for reporting this issue. For your application to work, as @rawalexe mentioned above, can you raise the priority of the coreMQTT-Agent? That will cause the agent to wake up as soon as your task adds any data to the agent queue and process it. This will cause your task to be preempted and sleep while the Agent uses the passed arguments to send publish packet. When it is done, your task will wake up and it will be okay to free the memory used by the arguments. Let us know if this works. Thanks, |
The MQTTAgent_Publish() method requires that the
pPublishInfo
argument (carrying the topic name) remains in scope after the call returns. This is not documented in the API doc, which only says:I am allocating the parameters to the Publish call on the stack, and do not want to wait for an ack, just send a fire-and-forget request. I can do this by setting the callback pointer to NULL. But that still doesn't work, because the library retains the
pPublishInfo
pointer. But that memory is deallocated when my method returns, leading to undefined behavior.Perhaps the library should make a copy of the supplied
MQTTPublishInfo_t
instead.The text was updated successfully, but these errors were encountered: