empiredan opened a new issue, #2270:
URL: https://github.com/apache/incubator-pegasus/issues/2270

   In https://github.com/apache/incubator-pegasus/pull/2267, underflow test for 
idempotent `incr` operation failed while adding 
`std::numeric_limits<int64_t>::min()` on `-1`:
   
   ```
   [==========] Running 1 test from 1 test suite.
   [----------] Global test environment set-up.
   [----------] 1 test from AtomicWriteTest/IncrTest
   W2025-07-10 08:22:14.927 (1752135734927678767 39986) unknown.io-thrd.39986: 
pegasus_client_factory_impl.cpp:48:initialize(): rdsn engine already started, 
ignore the config file 'conf
   ig.ini'
   [ RUN      ] AtomicWriteTest/IncrTest.Underflow/1
   create app incr_test_idempotent succeed, waiting for app ready
   incr_test_idempotent not ready yet, still waiting... (0/8)
   incr_test_idempotent not ready yet, still waiting... (0/8)
   incr_test_idempotent not ready yet, still waiting... (0/8)
   incr_test_idempotent not ready yet, still waiting... (0/8)
   incr_test_idempotent not ready yet, still waiting... (0/8)
   incr_test_idempotent not ready yet, still waiting... (0/8)
   incr_test_idempotent not ready yet, still waiting... (1/8)
   incr_test_idempotent not ready yet, still waiting... (5/8)
   incr_test_idempotent not ready yet, still waiting... (5/8)
   incr_test_idempotent is ready now: (8/8)
   incr_test_idempotent is ready now!
   /root/apache/pegasus/src/test/function_test/atomic_write/incr_test.cpp:174: 
Failure
   Expected equality of these values:
     PERR_INVALID_ARGUMENT
       Which is: -1004
     _client->incr( "incr_test_underflow", "", 
std::numeric_limits<int64_t>::min(), new_value_int)
       Which is: 0
   
   [  FAILED  ] AtomicWriteTest/IncrTest.Underflow/1, where GetParam() = 1-byte 
object <01> (20347 ms)
   [----------] 1 test from AtomicWriteTest/IncrTest (20347 ms total)
   
   [----------] Global test environment tear-down
   [==========] 1 test from 1 test suite ran. (20351 ms total)
   [  PASSED  ] 0 tests.
   [  FAILED  ] 1 test, listed below:
   [  FAILED  ] AtomicWriteTest/IncrTest.Underflow/1, where GetParam() = 1-byte 
object <01>
   
    1 FAILED TEST
   dsn exit with code 1
   ```
   
   While debugging on server side everything was normal except for the 
following statement:
   ```C++
   new_int = base_int + req.increment;
   ```
   
   According to https://en.cppreference.com/w/cpp/language/ub.html, overflow 
may lead to undefined behavior. Once `base_int` + `req.increment` overflows or 
underflows, something unexpected may occur.
   
   Though underflow test only happens while building Pegasus by release and 
ASAN with command `./run.sh build --test -t release -v -j $(nproc) --sanitizer 
address --disable_gperf` and testing idempotent `incr` operation, we should 
avoid anything that may lead to undefined behavior.
   
   Underflow tests were also run for the server-side 
`PegasusWriteServiceImplTest/IdempotentIncrTest`, which also failed as expected:
   
   ```
   [==========] Running 2 tests from 1 test suite.
   [----------] Global test environment set-up.
   [----------] 2 tests from PegasusWriteServiceImplTest/IdempotentIncrTest
   [ RUN      ] PegasusWriteServiceImplTest/IdempotentIncrTest.IncrUnderflow/0
   
/root/apache/pegasus/src/server/test/pegasus_write_service_impl_test.cpp:329: 
Failure
   Expected equality of these values:
     expected_err
       Which is: 4
     err
       Which is: 0
   
   
/root/apache/pegasus/src/server/test/pegasus_write_service_impl_test.cpp:400: 
Failure
   Expected equality of these values:
     kBaseValue
       Which is: -1
     err_resp.new_value
       Which is: 0
   
   [  FAILED  ] PegasusWriteServiceImplTest/IdempotentIncrTest.IncrUnderflow/0, 
where GetParam() = false (647 ms)
   [ RUN      ] PegasusWriteServiceImplTest/IdempotentIncrTest.IncrUnderflow/1
   
/root/apache/pegasus/src/server/test/pegasus_write_service_impl_test.cpp:329: 
Failure
   Expected equality of these values:
     expected_err
       Which is: 4
     err
       Which is: 0
   
   
/root/apache/pegasus/src/server/test/pegasus_write_service_impl_test.cpp:400: 
Failure
   Expected equality of these values:
     kBaseValue
       Which is: -1
     err_resp.new_value
       Which is: 0
   
   [  FAILED  ] PegasusWriteServiceImplTest/IdempotentIncrTest.IncrUnderflow/1, 
where GetParam() = true (541 ms)
   [----------] 2 tests from PegasusWriteServiceImplTest/IdempotentIncrTest 
(1188 ms total)
   
   [----------] Global test environment tear-down
   [==========] 2 tests from 1 test suite ran. (1188 ms total)
   [  PASSED  ] 0 tests.
   [  FAILED  ] 2 tests, listed below:
   [  FAILED  ] PegasusWriteServiceImplTest/IdempotentIncrTest.IncrUnderflow/0, 
where GetParam() = false
   [  FAILED  ] PegasusWriteServiceImplTest/IdempotentIncrTest.IncrUnderflow/1, 
where GetParam() = true
   
    2 FAILED TESTS
   dsn exit with code 1
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to