[ 
https://issues.apache.org/jira/browse/ORC-624?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18110501#comment-18110501
 ] 

Gang Wu commented on ORC-624:
-----------------------------

This issue still reproduces on current main.

UBSan reports a misaligned int16_t load in c++/src/LzoDecompressor.cc:240
while running TestDecompression.testLzoLong. The same unsafe pattern also
exists at line 201.

PR #496 proposed fixing both loads with memcpy, but it was closed as stale
and never merged. ORC-1041 fixed the wider output-copy operations only, and
ORC-2165 fixed the stop-command bounds check.

I plan to submit a focused patch replacing both trailer loads with
alignment-safe little-endian reads and use TestDecompression.testLzoLong as
the UBSan regression test.

> Undefined behaviour reports from UBSAN
> --------------------------------------
>
>                 Key: ORC-624
>                 URL: https://issues.apache.org/jira/browse/ORC-624
>             Project: ORC
>          Issue Type: Bug
>          Components: C++
>    Affects Versions: 1.6.2
>            Reporter: Ion Gaztañaga
>            Priority: Major
>
> While compiling the library using using gcc --version: "gcc (Ubuntu 
> 7.4.0-1ubuntu1~18.04.1) 7.4.0"
> Undefined defined sanitizer was activated which reported:
>  * Left-shift into sign-bit.
>  * Signed integer overflow when modulo behavior is intended
>  * Use memcpy (which modern compilers should optimize anyway) to avoid 
> unaligned reads
> Those UB can lead to unpredictable errors specially in high optimization 
> modes as the compiler is allowed to suppose the UB can't occur. Some 
> references:
> [https://trust-in-soft.com/blog/2020/04/06/gcc-always-assumes-aligned-pointers/]
> [https://kristerw.blogspot.com/2016/02/how-undefined-signed-overflow-enables.html]
>  
> A proposed pull request is available in the GitHub issue 
> ([https://github.com/apache/orc/pull/496]).
>  
>  



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

Reply via email to