Ticket #23 (new defect)

Opened 11 years ago

GCC with optimization causes different parsing result

Reported by: bennylp Owned by: bennylp
Priority: major Milestone: Known-Issues-and-Ideas
Component: common Version:
Keywords: Cc:
Backport to 1.x milestone: Backported:

Description

[Tested on mingw]

GCC 3.4.2 with optimization -O2 or higher produces different parsing result when parsing an invalid SIP message. This causes pjsip-test to fail in txdata_test(), when parsing a message. This test works fine when no optimization is specified in GCC, or with Visual C 6 compiler.

Note that this does NOT seem to affect the ultimate result of the parsing (by much). Valid messages will still be parsed okay, and invalid messages will still ultimately be rejected. The difference is, the bug causes the whole message to be rejected on syntax error, while the expected behavior is the parser should continue parsing the remainder of the message even when there is syntax error.

Below are screenshot of the test. Basically the test parses a SIP message (which indeed has incorrect Via header on line 2), but it is expected that the

Screenshot:

 14:16:13.718 txdata_test. 435 bytes request created:--begin-msg--
INVITE sip:alice@wonderland:5061;x-param=param%201 SIP/2.0
Via: SIP/2.0/ ;rport
Max-Forwards: 70
From:
<sip:alice@wonderland;x-param=param%201>;tag=2807a3ef41ff452994558c9bdf9fcbab
To: <sip:alice@wonderland;x-param=param%201>
Contact:
<sip:alice@wonderland:5061;x-param=param%201?X-Hdr-1=Header%201&X-Empty-Hdr>
Call-ID: 7e7ca9661bdf42e2a54ed061e3c612a5
CSeq: 381 INVITE
X-Hdr-1: Header 1
X-Empty-Hdr: 
Content-Length:  0


--end-msg--
 14:16:13.718 txdata_test.    error: parsing message message
 14:16:13.718 txdata_test.      PJSIP syntax error in line 2 col 16 hname=
 14:16:13.718 tdta003D9158 Destroying txdata Request msg INVITE/cseq=381
(tdta003D9158)
 14:16:13.718       test.c ..ERROR(-255)

There is a compilation switch in PJSIP-TEST to test this bug. Enable with #define INCLUDE_GCC_TEST 1 in test.h (default is 0).

Note: See TracTickets for help on using tickets.