Arjun Ray created AMQCPP-759:
--------------------------------

             Summary: src/main/decaf/lang/Long.cpp does not detect overflow 
properly
                 Key: AMQCPP-759
                 URL: https://issues.apache.org/jira/browse/AMQCPP-759
             Project: ActiveMQ C++ Client
          Issue Type: Bug
          Components: Decaf
    Affects Versions: 3.9.4, 3.9.3, 3.9.2, 3.9.1, 3.9.0, 3.9.5
            Reporter: Arjun Ray
            Assignee: Timothy A. Bish


The code involves a defective test for overflow. 
{color:#cccccc}        {color}{color:#c586c0}if{color}{color:#cccccc} 
({color}{color:#9cdcfe}max{color}{color:#cccccc} 
{color}{color:#d4d4d4}>{color}{color:#cccccc} 
{color}{color:#9cdcfe}result{color}{color:#cccccc}) {{color}
{color:#cccccc}            {color}{color:#c586c0}throw{color}{color:#cccccc} 
{color}{color:#4ec9b0}exceptions{color}{color:#cccccc}::{color}{color:#4ec9b0}NumberFormatException{color}{color:#cccccc}({color}{color:#569cd6}__FILE__{color}{color:#cccccc},
 {color}{color:#569cd6}__LINE__{color}{color:#cccccc},{color}
{color:#cccccc}                {color}{color:#ce9178}"Long::parseLong - Parsed 
value greater than max for radix."{color}{color:#cccccc});{color}
{color:#cccccc}        }{color}
The bug shows up when the code base is compiled with optimization turned on 
(typically, with -O2).  With that the compiler (gcc) assumes that overflow will 
not occur and therefore does not even check for it.  As a result, an exception 
is not thrown, which causes a unit test (which was expecting the exception for 
invalid input) to fail.  Without optimization, the overflow causes undefined 
behavior (according to the C++ standards), which in this particular case 
results in the unit test passing accidentally.

This bug occurs only with unusual inputs, but in theory should not be present 
at all with a correct implementation of overflow detection.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to