-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[gcoap-dtls] Posting a message yields a stack overflow on the samr21-xpro
with ECC
#18292
Comments
Just to add a few more details here, the firmware I am using (about 170 lines, I do not want to post all), roughly performs this in one thread: void *data_thread(void *arg) {
(void)arg;
uint8_t buf[CONFIG_GCOAP_PDU_BUF_SIZE];
memset(buf, 0, CONFIG_GCOAP_PDU_BUF_SIZE);
// Put packet metadata
coap_pkt_t pdu = {};
gcoap_req_init(&pdu, buf, CONFIG_GCOAP_PDU_BUF_SIZE, COAP_POST, "/data");
coap_opt_add_format(&pdu, COAP_FORMAT_CBOR);
coap_hdr_set_type(pdu.hdr, COAP_TYPE_NON);
ssize_t meta_len = coap_opt_finish(&pdu, COAP_OPT_FINISH_PAYLOAD);
while (true) {
// Write some data to `buf`
size_t payload_len = ...;
// Post data
gcoap_req_send(buf, meta_len + payload_len, &host_ep, NULL, NULL);
// Some cleanup
}
return NULL;
} And the DTLS proxy I am working on roughly does this in its unsafe extern "C" fn server_write_callback(
ctx: *mut dtls_context_t,
session: *mut session_t,
buf: *mut u8,
len: c_size_t,
) -> c_int {
debug_println!("WRITE");
let socket = (*ctx).app as *mut UdpSocket;
let addr = session.as_ref().unwrap().addr.sin6.as_ref();
assert!(addr.sin6_family == AF_INET6 as u16);
(*socket)
.send_to(
std::slice::from_raw_parts(buf, len as usize),
SocketAddrV6::new(
Ipv6Addr::from(addr.sin6_addr.s6_addr),
u16::from_be(addr.sin6_port),
addr.sin6_flowinfo,
addr.sin6_scope_id,
),
)
.expect(debug_fmt!("Failed to send message"));
0
} |
Can you invrease the stacksize a lot, and then get |
I already tried that. I do not have the output at hand, but I increased the stack size of the COAP Thread to > 4096 (in the RIOT source, there are some additions there) and by the time of the hardfault it used up all of it. Before that, I think about 700 bytes. I can provide a |
Can't do much testing here but could you try moving |
Excuse the late reply, Still not working, but we are now switching to PSKs and that does not seem to crash. Anyways, @kaspar030 here is an idle PS of
This stack usage seems reasonable. I cannot see more, since after crashing I can only restart the board. I now multiplied the
And the above command still crashes. @cgundogan I tried your idea, it still crashes. :( |
samr21-xpro
samr21-xpro
with ECC
ECC is known to be flaky with TinyDTLS, so I think it is good to keep this open as a known issue. |
There is more info on ECC on microcontrollers on the forum btw. Could also be of interest to you. |
@valentinpi sorry for the late reply. Could you try it again with increasing the stack size? But this time, please increase the stack size of the
indicates that the |
Thank you so much for the reply, but I sadly cannot access my board right now :(. May we close the issue and could I reopen it in the case I get back to this again please? |
Sure. If the issue arises again, I'm happy to assist solving :) |
Description
The
gcoap-dtls
example leads to a stack overflow after executing a post command.Steps to reproduce the issue
After flashing the board and executing `$ coap post fc00:: 5684
gcoap-dtls
test on a board and execute the terminal:# coap post fc00:: 5684 / Hi!
Expected results
No matter whether a server is listening on
fc00::
or not, the non-confirmable POST message should just be sent out and appear in Wireshark.Actual results
This output:
Versions
The current RIOT master branch.
Additional Information
I am currently writing a small DTLS proxy for a Node JS backend, since DTLS support there is quite terrible, and with
tinydtls-rs
I have developed a small Rust application to listen for DTLS packets from the board and decrypt them for the backend. However, with my application, I also get a stack overflow inpid=6
, which is thecoap
thread, and then a hard fault. I decided to test this example, where I got the above problem. The Rust application is working however, and sending the handshake, but the client is not responding.The text was updated successfully, but these errors were encountered: