[ 
https://issues.apache.org/jira/browse/ORC-314?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Quanlong Huang updated ORC-314:
-------------------------------
    Affects Version/s: 1.0.0
                       1.1.2
                       1.2.3
                       1.3.4

> C++ Reader crash for out of range scale in parsing decimals
> -----------------------------------------------------------
>
>                 Key: ORC-314
>                 URL: https://issues.apache.org/jira/browse/ORC-314
>             Project: ORC
>          Issue Type: Bug
>          Components: C++
>    Affects Versions: 1.0.0, 1.1.2, 1.2.3, 1.3.4, 1.4.3
>            Reporter: Quanlong Huang
>            Priority: Major
>         Attachments: decimal_ill_scale.orc
>
>
> The c++ reader crash in parsing the attached file. It's a corrupt orc file 
> with decimal values.
> {code}
> $ build/tools/src/orc-scan decimal_ill_scale.orc 
> Floating point exception (core dumped)
> {code}
> This is a devided-by-zero error:
> {code}
> Core was generated by `build/tools/src/orc-scan decimal_ill_scale.orc'.
> Program terminated with signal SIGFPE, Arithmetic exception.
> #0  0x0000000000896c0d in orc::Decimal64ColumnReader::readInt64 
> (this=0x1010120, value=@0x101aa60: 2222, currentScale=95) at 
> /mnt/volume1/orc/c++/src/ColumnReader.cc:1177
> 1177            value /= POWERS_OF_TEN[currentScale - scale];
> (gdb) bt
> #0  0x0000000000896c0d in orc::Decimal64ColumnReader::readInt64 
> (this=0x1010120, value=@0x101aa60: 2222, currentScale=95) at 
> /mnt/volume1/orc/c++/src/ColumnReader.cc:1177
> #1  0x0000000000895700 in orc::Decimal64ColumnReader::next (this=0x1010120, 
> rowBatch=..., numValues=5, notNull=0x0) at 
> /mnt/volume1/orc/c++/src/ColumnReader.cc:1268
> #2  0x0000000000893880 in orc::StructColumnReader::next (this=0xff9720, 
> rowBatch=..., numValues=5, notNull=0x0) at 
> /mnt/volume1/orc/c++/src/ColumnReader.cc:813
> #3  0x0000000000833e86 in orc::RowReaderImpl::next (this=0x10044b0, data=...) 
> at /mnt/volume1/orc/c++/src/Reader.cc:832
> #4  0x000000000082d274 in scanFile (out=..., filename=0x7ffc132d3755 
> "decimal_ill_scale.orc", batchSize=1024) at 
> /mnt/volume1/orc/tools/src/FileScan.cc:39
> #5  0x000000000082d4c5 in main (argc=1, argv=0x7ffc132d1940) at 
> /mnt/volume1/orc/tools/src/FileScan.cc:84
> (gdb) p currentScale
> $1 = 95
> (gdb) p scale
> $2 = 0
> {code}
> 95 is out of the length of the POWERS_OF_TEN array. So it gets value 0 
> unexpectedly.
> {code}
>   class Decimal64ColumnReader: public ColumnReader {
>   public:
>     static const uint32_t MAX_PRECISION_64 = 18;
>     static const uint32_t MAX_PRECISION_128 = 38;
>     static const int64_t POWERS_OF_TEN[MAX_PRECISION_64 + 1];
> {code}
> We should check the range of currentScale in Decimal64ColumnReader::readInt64 
> to avoid this.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to