contiki-os / contiki

The official git repository for Contiki, the open source OS for the Internet of Things
http://www.contiki-os.org/
Other
3.71k stars 2.58k forks source link

Writing to read-only P3IN #2175

Closed Shridharfly closed 7 years ago

Shridharfly commented 7 years ago

I am trying to compute hash of IPv6 packet after header compression using quark. The hash is computed over compressed IPv6 header and payload.

This line mentions that the IP packet is initially in uip_buf and uip_len gives the length of the contents in uip_buf.

The prototype of quark is int quark( u8 *out, const u8 *in, u64 inlen );

I am calling quark( out, uip_buf, uip_len ); after IPv6 header compression. I compute hash only if the packet is large enough to be fragmented.

I am using z1 motes, cooja simulator in contiki 3.0. I am getting the following issue :

[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) - Writing to read-only P3IN
[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) - 
[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) - Stack Trace: number of calls: 13 PC: $07a36
[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) -   permute_u (serial-line.c) called from PC: $07f76 (elapsed: 890)
[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) -   permute (local in sicslowpan.c) called from PC: $0806e (elapsed: 49789)
[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) -   update (serial-line.c) called from PC: $08150 (elapsed: 70287)
[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) -   quark (serial-line.c) called from PC: $0874e (elapsed: 127697)
[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) -   output (local in sicslowpan.c) called from PC: $0a288 (elapsed: 247738)
[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) -   tcpip_output (serial-line.c) called from PC: $0a3b8 (elapsed: 247750)
[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) -   tcpip_ipv6_output (serial-line.c) called from PC: $09ffa (elapsed: 247800)
[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) -   uip_icmp6_send (serial-line.c) called from PC: $0c066 (elapsed: 248724)
[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) -   dis_output (serial-line.c) called from PC: $0c79c (elapsed: 248786)
[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) -   handle_periodic_timer (local in rpl-timers.c) called from PC: $06496 (elapsed: 249098)
[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) -   process_thread_ctimer_process (local in ctimer.c) called from PC: $068aa (elapsed: 249237)
[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) -   call_process (local in process.c) called from PC: $06a28 (elapsed: 249272)
[java]  INFO [AWT-EventQueue-0] (MessageListUI.java:261) -   process_run (serial-line.c) called from PC: $033f2 (elapsed: 250282)

After some search I understood that possible reasons can be:

  1. A function returns negative or large number.
  2. Array index out of bounds.

I am sure about no such possibility in my code but I don't know if any possibility in quark.c. I am just using rpl-udp client and server. I am sending only 134 bytes of data from client as data.

Just before the error pops up, Mote output displayed the values that I had printed from the code. uip_len = 116 sizeof(uip_buf) = 1280

Any solution or hints to get rid of the error?

Shridharfly commented 7 years ago

Calls to malloc fail in contiki. So the issue.