1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
diff --git a/gdb_arrow.py b/gdb_arrow.py
index 6c3af1680..ad40ec499 100644
--- a/gdb_arrow.py
+++ b/gdb_arrow.py
@@ -304,7 +304,8 @@ def format_timestamp(val, unit):
seconds, subseconds = divmod(val, traits.multiplier)
try:
dt = datetime.datetime.utcfromtimestamp(seconds)
- except (ValueError, OSError): # value out of range for datetime.datetime
+ except (ValueError, OSError, OverflowError):
+ # value out of range for datetime.datetime
pretty = "too large to represent"
else:
pretty = dt.isoformat().replace('T', ' ')
diff --git a/src/arrow/io/file.cc b/src/arrow/io/file.cc
index 543fa90a8..3b18bb7b0 100644
--- a/src/arrow/io/file.cc
+++ b/src/arrow/io/file.cc
@@ -36,6 +36,7 @@
#include <cerrno>
#include <cstdint>
#include <cstring>
+#include <limits>
#include <memory>
#include <mutex>
#include <sstream>
@@ -560,17 +561,22 @@ class MemoryMappedFile::MemoryMap
RETURN_NOT_OK(::arrow::internal::FileTruncate(file_->fd(), initial_size));
}
- size_t mmap_length = static_cast<size_t>(initial_size);
- if (length > initial_size) {
- return Status::Invalid("mapping length is beyond file size");
- }
- if (length >= 0 && length < initial_size) {
+ int64_t mmap_length = initial_size;
+ if (length >= 0) {
// memory mapping a file region
- mmap_length = static_cast<size_t>(length);
+ if (length > initial_size) {
+ return Status::Invalid("mapping length is beyond file size");
+ }
+ mmap_length = length;
+ }
+ if (static_cast<int64_t>(static_cast<size_t>(mmap_length)) != mmap_length) {
+ return Status::CapacityError("Requested memory map length ", mmap_length,
+ " does not fit in a C size_t "
+ "(are you using a 32-bit build of Arrow?");
}
- void* result = mmap(nullptr, mmap_length, prot_flags_, map_mode_, file_->fd(),
- static_cast<off_t>(offset));
+ void* result = mmap(nullptr, static_cast<size_t>(mmap_length), prot_flags_, map_mode_,
+ file_->fd(), static_cast<off_t>(offset));
if (result == MAP_FAILED) {
return Status::IOError("Memory mapping file failed: ",
::arrow::internal::ErrnoMessage(errno));
|