<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div>Hi,</div><div><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; ">My solution is rename stun_message_length() on libnice.</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; ">My application can works now.</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; "><br></div>  <div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; "> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b>
 Youness Alaoui <youness.alaoui@collabora.co.uk><br> <b><span style="font-weight: bold;">To:</span></b> ly tran <congly85@yahoo.com> <br><b><span style="font-weight: bold;">Cc:</span></b> "nice@lists.freedesktop.org" <nice@lists.freedesktop.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Saturday, September 1, 2012 1:09 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [Nice] Segmentation fault with libnice-0.1.2 on ARM ( Nokia N9)<br> </font> </div> <br>
Oh I see, now it makes sense!. Thanks and good job on finding that, that's a<br>very tricky situation. I don't know about sofia-sip, but libnice exports that<br>function as part of its API, so it has to be named that way and it has to be an<br>exportable symbol. I suppose the same for sofia-sip, so I'm not sure the best<br>solution of fixing that would be. There might be some compiler option or at<br>least a way to make sure that all functions within libnice.so are linked to the<br>right internal function.<br>Let me know if you find a way to work around this. thanks<br><br>On 08/31/2012 12:40 PM, ly tran wrote:<br>> Hi,<br>> <br>> Problem cleared.<br>> My program used sofia-sip and libnice library. But both sofia-sip and libnice<br>> have stun_message_length () function, so it's my problem.<br>> My program always link to stun_message_length() of sofia-sip instead of libnice.<br>> <br>> Thanks for your support.<br>>
 --------------------------------------------------------------------------------<br>> *From:* Youness Alaoui <<a ymailto="mailto:youness.alaoui@collabora.co.uk" href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a>><br>> *To:* ly tran <<a ymailto="mailto:congly85@yahoo.com" href="mailto:congly85@yahoo.com">congly85@yahoo.com</a>><br>> *Cc:* "<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>" <<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>><br>> *Sent:* Tuesday, August 28, 2012 11:26 PM<br>> *Subject:* Re: [Nice] Segmentation fault with libnice-0.1.2 on ARM ( Nokia N9)<br>> <br>> That makes no sense :<br>> The stun_sha1 function is called with the stun_message_length() return value as<br>> argumnent :<br>>          
 stun_sha1 (msg->buffer, stun_message_length (msg),<br>>               stun_message_length (msg) - minus, ptr, key, key_len, TRUE);<br>> So there is no way that stun_message_length doesn't get called... or that it<br>> returns -1 without calling it.<br>> Maybe that's your problem though.. maybe your ARM compiler is somehow optimizing<br>> that function out and puts -1 instead?<br>> <br>> On 08/28/2012 04:05 AM, ly tran wrote:<br>>> Hi,<br>>><br>>> uint16_t stun_message_length (const StunMessage *msg)<br>>> {<br>>>  return stun_getw (msg->buffer + STUN_MESSAGE_LENGTH_POS) +<br>>>      STUN_MESSAGE_HEADER_LENGTH;<br>>> }<br>>><br>>> the STUN_MESSAGE_HEADER_LENGTH is equal to 20, and the stun_getw is just<br>>> returning the uint16 value in the (buffer + 2) memory... so for the<br>>> stun_message_length to
 return -1, it means that the exact value at the offset 2<br>>> in the buffer has to be -21 since stun_message_length returns the getw + 20...<br>>> This seems to be consistent with what your new debug messages seem to be<br>>> printing. If you also add to it that in your case, you're saying that "msg" is<br>>> NULL, it means that stun_message_length shouldn't have returned -1, it should<br>>> have segfaulted when trying to access msg->buffer.<br>>><br>>> I debug and know that libnice never goes into stun_message_length() function.<br>>> It's always return -1.<br>>><br>>> --------------------------------------------------------------------------------<br>>> *From:* Youness Alaoui <<a ymailto="mailto:youness.alaoui@collabora.co.uk" href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a><br>> <mailto:<a ymailto="mailto:youness.alaoui@collabora.co.uk"
 href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a>>><br>>> *To:* <a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>>;<br>> <a ymailto="mailto:congly85@yahoo.com" href="mailto:congly85@yahoo.com">congly85@yahoo.com</a> <mailto:<a ymailto="mailto:congly85@yahoo.com" href="mailto:congly85@yahoo.com">congly85@yahoo.com</a>><br>>> *Sent:* Friday, August 17, 2012 3:53 AM<br>>> *Subject:* Re: [Nice] Segmentation fault with libnice-0.1.2 on ARM ( Nokia N9)<br>>><br>>> Hi,<br>>><br>>> I see you added a lot of debug to figure out the issue. But this looks<br>>> completely wrong.<br>>> Libnice itself works fine on ARM (it is shipped and used by Meego/Harmattan
 on<br>>> the N9) and it looks like there is some sort of stack corruption in the backlog<br>>> you sent me...<br>>> The &pair->stun_message could not be NULL, because stun_message is not a<br>>> dynamically allocated pointer, it's structure inside the CandidateCheckPair<br>>> structure and it's returning its pointer so it can't be NULL (unless 'pair' is<br>>> equal to exactly the negative value of the offset in the structure of the<br>>> stun_message field).<br>>> What I could analyze is this :<br>>> The crash happens in memcpy called by SHA1Transform when it tries to copy data<br>>> (to sha1) to an internal buffer. The reason is that the source data it tries to<br>>> copy is outside the allocated memory.<br>>> The problem is that it thinks the size of the data that needs to be hashed is<br>>> 4294967267... that is equal to 0xFFFFFFE3 which is, in signed format :
 -29<br>>> The -29 comes from this :<br>>>  lengths[2] = len - 28;<br>>> Which means that the original length of the stun message was thought to be<br>>> "-1"... that in itself makes no sense because the length is returned from<br>>> stun_message_length() which itself is :<br>>> uint16_t stun_message_length (const StunMessage *msg)<br>>> {<br>>>  return stun_getw (msg->buffer + STUN_MESSAGE_LENGTH_POS) +<br>>>      STUN_MESSAGE_HEADER_LENGTH;<br>>> }<br>>><br>>> the STUN_MESSAGE_HEADER_LENGTH is equal to 20, and the stun_getw is just<br>>> returning the uint16 value in the (buffer + 2) memory... so for the<br>>> stun_message_length to return -1, it means that the exact value at the offset 2<br>>> in the buffer has to be -21 since stun_message_length returns the getw + 20...<br>>> This seems to be consistent with what your new debug
 messages seem to be<br>>> printing. If you also add to it that in your case, you're saying that "msg" is<br>>> NULL, it means that stun_message_length shouldn't have returned -1, it should<br>>> have segfaulted when trying to access msg->buffer.<br>>><br>>> There's also this stuff that seems weird :<br>>>        uname_len = 1004972<br>>>        password_len = 1004972<br>>> key_len=2929302848, num_elem=2, (even though previous function in the stack<br>>> trace shows key_len = 22, and num_elem=3)<br>>> The problem still remains that the message_length is thought to be -1<br>>> (0xFFFFFFFF) and that's what's causing all the other issues. Even the 'fakelen'<br>>> variable (which is a htons of the len) is set to 65535.<br>>><br>>> From all this, all I can conclude is that, you're either doing something wrong,<br>>> or you're
 using a heavily modified library which I have no idea what it does, or<br>>> your ram/whatever is being corrupted somehow, or your compiler is not generating<br>>> proper code, or there's a demon in your phone that's playing tricks on you!<br>>> But this is seriously a weird issue you're having and I have no idea how to even<br>>> begin to fix it.<br>>> If you get any more info/details on the cause, let me know, I'll give it another<br>>> look.<br>>><br>>> Good luck!<br>>> Youness.<br>>><br>>><br>>><br>>><br>>><br>>><br>>> On 08/16/2012 04:18 AM, ly tran wrote:<br>>>> Hi,<br>>>><br>>>> Here is my debug result:<br>>>> In file: conncheck.c, function conn_check_send(), the segmentation occur at line<br>>>> buffer_len = stun_usage_ice_conncheck_create (&agent->stun_agent,<br>>>>     
   &pair->stun_message, pair->stun_buffer, sizeof(pair->stun_buffer),<br>>>>        uname, uname_len, password, password_len,<br>>>>        cand_use, controlling, priority,<br>>>>        agent->tie_breaker,<br>>>>        pair->foundation,<br>>>>        agent_to_ice_compatibility (agent));<br>>>> I checked that &pair->stun_message is null and step into this function to follow<br>>>> this variable. It's always null until segmentation.<br>>>><br>>>> Please refer backtrace in attachment for more details.<br>>>><br>>>> Thanks<br>>>> --------------------------------------------------------------------------------<br>>>> *From:* Youness Alaoui <<a ymailto="mailto:youness.alaoui@collabora.co.uk"
 href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a><br>> <mailto:<a ymailto="mailto:youness.alaoui@collabora.co.uk" href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a>><br>>> <mailto:<a ymailto="mailto:youness.alaoui@collabora.co.uk" href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a> <mailto:<a ymailto="mailto:youness.alaoui@collabora.co.uk" href="mailto:youness.alaoui@collabora.co.uk">youness.alaoui@collabora.co.uk</a>>>><br>>>> *To:* <a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>><br>> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>
 <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>>><br>>>> *Sent:* Wednesday, August 15, 2012 9:04 PM<br>>>> *Subject:* Re: [Nice] Segmentation fault with libnice-0.1.2 on ARM ( Nokia N9)<br>>>><br>>>> Hi,<br>>>><br>>>> Could you provide a gdb backtrace with "bt full" so I can look into what's<br>>>> causing it exactly?<br>>>><br>>>> Thanks,<br>>>> Youness<br>>>><br>>>> On 08/15/2012 05:56 AM, ly tran wrote:<br>>>>> Hi,<br>>>>><br>>>>> I use libnice to make video call using SIP (sofia-sip) signalling protocol.<br>>>>> I used sofsip_cli example in sofia-sip-1.12.11.<br>>>>> I can make successfull video call in x86 (Ubuntu dekstop).<br>>>>> But when I compile and run on ARM (Nokia N9), I got
 the following segmentation<br>>>>> fault at: nice_agent_set_remote_candidates() function<br>>>>> Is there anybody have the same problem ?<br>>>>><br>>>>> ** Message: parsing SDP:<br>>>>> v=0<br>>>>> m=video 32931 RTP/AVP 98<br>>>>> c=IN IP4 192.168.2.15<br>>>>> a=rtpmap:98 theora/90000<br>>>>> a=candidate:1 1 UDP 2013266431 192.168.2.15 32931 typ host<br>>>>> a=candidate:2 1 UDP 2013266431 169.254.41.172 48865 typ host<br>>>>> a=candidate:1 2 UDP 2013266430 192.168.2.15 57849 typ host<br>>>>> a=candidate:2 2 UDP 2013266430 169.254.41.172 43299 typ host<br>>>>> a=ice-pwd:sIX8Lqas8Lk1TSgIBboFST<br>>>>> a=ice-ufrag:owAy<br>>>>> a=rtcp:57849<br>>>>><br>>>>> ---<br>>>>> ** Message: priv_refresh_nice
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<br>>>>> ** Message: priv_set_remote_v_sdp_candidates<br>>>>> ** (sofsip_cli:1356): DEBUG: Found ice-ufrag:cyES<br>>>>> ** (sofsip_cli:1356): DEBUG: Found ice-pwd:mYErzMCqTWU+2vZJAQ8uuK<br>>>>> ** Message: Remote does not support ICE, falling back to non-ICE mode.<br>>>>> ** Message: nice_agent_set_remote_candidates START<br>>>>> (sofsip_cli:1356): libnice-DEBUG: Agent 0xc19a8: set_remote_candidates 1 1<br>>>>> (sofsip_cli:1356): libnice-DEBUG: Agent 0xc19a8 : Adding remote candidate with<br>>>>> addr [192.168.2.15]:33462 for s1/c1. U/P '(null)'/'(null)' prio: 1<br>>>>> (sofsip_cli:1356): libnice-DEBUG: Agent 0xc19a8 : creating new pair 0xf3000<br>>>> state 5<br>>>>> (sofsip_cli:1356): libnice-DEBUG: Agent 0xc19a8 : added a new conncheck 0xf3000<br>>>>> with foundation of '1:1'
 to list 1.<br>>>>> (sofsip_cli:1356): libnice-DEBUG: Agent 0xc19a8 : stream 1 component 1<br>>>>> STATE-CHANGE 1 -> 2.<br>>>>> ** Message: priv_cb_component_state_changed: stream_id=1, component_id=1,<br>>>>> state=2, self=0xbfc10<br>>>>> ** Message: rtp comp 1, rtcp com 2, ready 4, disconnected 0 failed 5<br>>>>> ** Message: goes here<br>>>>> (sofsip_cli:1356): libnice-DEBUG: Agent 0xc19a8 : creating new pair 0x1030b0<br>>>> state 5<br>>>>> (sofsip_cli:1356): libnice-DEBUG: Agent 0xc19a8 : added a new conncheck 0x1030b0<br>>>>> with foundation of '2:1' to list 1.<br>>>>> (sofsip_cli:1356): libnice-DEBUG: Agent 0xc19a8 : Pair 0xf3000 with s/c-id 1/1<br>>>>> (1:1) unfrozen.<br>>>>> (sofsip_cli:1356): libnice-DEBUG: Agent 0xc19a8 : pair 0xf3000 state WAITING<br>>>>> (sofsip_cli:1356):
 libnice-DEBUG: Agent 0xc19a8 : priv_conn_check_unfreeze_next<br>>>>> returned 1<br>>>>> (sofsip_cli:1356): libnice-DEBUG: Agent 0xc19a8 : pair 0xf3000 state IN_PROGRESS<br>>>>> (sofsip_cli:1356): libnice-DEBUG: Agent 0xc19a8 : STUN-CC REQ to<br>>>>> '192.168.2.15:33462', socket=11, pair=1:1 (c-id:1), tie=2663607996370330830,<br>>>>> username='cyES:owAy' (9), password='mYErzMCqTWU+2vZJAQ8uuK' (22),<br>>>>> priority=1845494271.<br>>>>> Segmentation fault<br>>>>><br>>>>><br>>>>> _______________________________________________<br>>>>> nice mailing list<br>>>>> <a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>><br>>
 <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>>><br>>> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>><br>> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>>>><br>>>>> <a href="http://lists.freedesktop.org/mailman/listinfo/nice"
 target="_blank">http://lists.freedesktop.org/mailman/listinfo/nice</a><br>>>><br>>>><br>>>><br>>>> _______________________________________________<br>>>> nice mailing list<br>>>> <a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>><br>> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>>><br>>> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org"
 href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>><br>> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>>>><br>>>> <a href="http://lists.freedesktop.org/mailman/listinfo/nice" target="_blank">http://lists.freedesktop.org/mailman/listinfo/nice</a><br>>>><br>>>><br>>>><br>>>><br>>>> _______________________________________________<br>>>> nice mailing list<br>>>> <a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>><br>> <mailto:<a
 ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>>><br>>>> <a href="http://lists.freedesktop.org/mailman/listinfo/nice" target="_blank">http://lists.freedesktop.org/mailman/listinfo/nice</a><br>>><br>>><br>>><br>>> _______________________________________________<br>>> nice mailing list<br>>> <a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>><br>> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a> <mailto:<a
 ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>>><br>>> <a href="http://lists.freedesktop.org/mailman/listinfo/nice" target="_blank">http://lists.freedesktop.org/mailman/listinfo/nice</a><br>>><br>>><br>> <br>> <br>> <br>> _______________________________________________<br>> nice mailing list<br>> <a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a> <mailto:<a ymailto="mailto:nice@lists.freedesktop.org" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>><br>> <a href="http://lists.freedesktop.org/mailman/listinfo/nice" target="_blank">http://lists.freedesktop.org/mailman/listinfo/nice</a><br>> <br>> <br><br><br><br>_______________________________________________<br>nice mailing list<br><a ymailto="mailto:nice@lists.freedesktop.org"
 href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a><br><a href="http://lists.freedesktop.org/mailman/listinfo/nice" target="_blank">http://lists.freedesktop.org/mailman/listinfo/nice</a><br><br><br> </div> </div>  </div></body></html>