{"action":"opened","issue":{"url":"https://api.github.com/repos/cetic/6lbr/issues/93","labels_url":"https://api.github.com/repos/cetic/6lbr/issues/93/labels{/name}","comments_url":"https://api.github.com/repos/cetic/6lbr/issues/93/comments","events_url":"https://api.github.com/repos/cetic/6lbr/issues/93/events","html_url":"https://github.com/cetic/6lbr/issues/93","id":92695914,"number":93,"title":"tcpip_icmp6_call( ) problem in tcpip.c","user":{"login":"tjrendall","id":9356485,"avatar_url":"https://avatars.githubusercontent.com/u/9356485?v=3","gravatar_id":"","url":"https://api.github.com/users/tjrendall","html_url":"https://github.com/tjrendall","followers_url":"https://api.github.com/users/tjrendall/followers","following_url":"https://api.github.com/users/tjrendall/following{/other_user}","gists_url":"https://api.github.com/users/tjrendall/gists{/gist_id}","starred_url":"https://api.github.com/users/tjrendall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjrendall/subscriptions","organizations_url":"https://api.github.com/users/tjrendall/orgs","repos_url":"https://api.github.com/users/tjrendall/repos","events_url":"https://api.github.com/users/tjrendall/events{/privacy}","received_events_url":"https://api.github.com/users/tjrendall/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-02T17:54:20Z","updated_at":"2015-07-02T17:54:20Z","closed_at":null,"body":"Hi Everyone,\r\n\r\nI was recently having issues running my 6LBR implementation for long periods of time while connected to the internet. \r\n\r\nIn the file, tcpip.c, there is a function tcpip_icmp6_call, which has a “XXX hack” message.\r\n\r\nIt seems as though for internet-enabled applications (as in the ping6 example), the icmp6_new function is called with NULL to initialize the uip_icmp6_conns structure.\r\n\r\nHowever, after some amount of time, the memory used by “uip_icmp6_conns” is overwritten, causing the line: \r\n\r\n               “process_post_synch(uip_icmp6_conns.appstate.p, tcpip_icmp6_event, &type);” \r\n\r\nto throw a hard-fault on the MCU when an icmp6 message is received from the internet (i.e. NDP).\r\n\r\nI have found that this is because “uip_icmp6_conns.appstate.p” is not a static object. When it is used properly, it points to a process and all that process’ properties. When this pointer’s target has been overwritten, the “process_post_synch” function fails, since the process it calls is some arbitrary memory location, not a process at all.\r\n\r\nMy solution is to move the declaration of uip_icmp6_conns from uip6.c to the top of tcpip.c, and add the “static” declaration modifier.\r\n\r\ni.e. globally declaring the variable as:\r\n\r\n                static struct uip_icmp6_conn uip_icmp6_conns;\r\n\r\ninstead of: \r\n\r\n                struct uip_icmp6_conn uip_icmp6_conns;\r\n\r\nat the top of tcpip.c (the only file that uip_icmp6_conns is used in).\r\n\r\nAdditionally, in uip.h, the extern declaration of uip_icmp6_conns should be removed, since it is not even used in uip.h.\r\n\r\nWith uip_icmp6_conns set as a global static structure in tcpip.c (the only file in which it is used), the memory it uses will never be overwritten during the lifetime of the program, and therefore, when the internet-enabled application receives an icmp6 message such as an NDP handshake it will be able to run the appropriate process.\r\n\r\nI have implemented this on my 6LBR and apparently eliminated the issues causing the hard-faults.\r\n\r\nThoughts?\r\n\r\nJordan\r\n"}}