8000 enable ASAN/UBSAN in pandas CI by WillAyd · Pull Request #55102 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

enable ASAN/UBSAN in pandas CI #55102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 57 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
4220d82
Merge branch 'main' into pandas-asan
WillAyd Nov 16, 2023
46d1034
reverts
WillAyd Nov 16, 2023
89706a4
Merge branch 'main' into pandas-asan
WillAyd Nov 17, 2023
929c731
known UB marker
WillAyd Nov 17, 2023
b01242b
Merge branch 'main' into pandas-asan
lithomas1 Nov 28, 2023
6483e07
Finished marking tests with known UB
WillAyd Dec 2, 2023
de13605
Merge remote-tracking branch 'upstream/main' into pandas-asan
WillAyd Dec 2, 2023
b87a210
dedicated CI job
WillAyd Dec 2, 2023
77d1e00
Merge remote-tracking branch 'upstream/main' into pandas-asan
WillAyd Dec 2, 2023
46ec023
identifier fix
WillAyd Dec 2, 2023
8695dca
fixes
WillAyd Dec 2, 2023
05319ae
more test skip
WillAyd Dec 2, 2023
6d76a57
try quotes
WillAyd Dec 2, 2023
f5dd440
simplify ci
WillAyd Dec 2, 2023
12aa1d1
try CFLAGS
WillAyd Dec 2, 2023
628d1c2
preload args
WillAyd Dec 2, 2023
1de633e
skip single_cpu tests
WillAyd Dec 2, 2023
3e295c5
wording
WillAyd Dec 2, 2023
252197e
Merge remote-tracking branch 'upstream/main' into pandas-asan
WillAyd Dec 5, 2023
d5809b8
removed unneeded marker
WillAyd Dec 5, 2023
6266422
float set implementations
WillAyd Dec 5, 2023
b68a533
Revert "float set implementations"
WillAyd Dec 5, 2023
47dc305
Merge branch 'main' into pandas-asan
WillAyd Dec 6, 2023
636b8dd
Merge remote-tracking branch 'upstream/main' into pandas-asan
WillAyd Dec 13, 2023
a03ad1e
change marker name
WillAyd Dec 15, 2023
656edb1
dedicated actions file
WillAyd Dec 15, 2023
2aabda1
consolidated into matrix
WillAyd Dec 15, 2023
a9f2419
Merge remote-tracking branch 'upstream/main' into pandas-asan
WillAyd Dec 15, 2023
3056e5f
fixup
WillAyd Dec 15, 2023
89b2b80
typos
WillAyd Dec 15, 2023
d591b78
fixups
WillAyd Dec 16, 2023
6442066
add qt?
WillAyd Dec 16, 2023
c59703d
Merge branch 'main' into pandas-asan
WillAyd Dec 19, 2023
02bf20d
intentional UB with verbose
WillAyd Dec 19, 2023
01070f3
disable pytest-xdist
WillAyd Dec 20, 2023
9f1adbc
Merge remote-tracking branch 'upstream/main' into pandas-asan
WillAyd Dec 20, 2023
57ed286
original issue
WillAyd Dec 20, 2023
677da0e
remove UB
WillAyd Dec 20, 2023
af0150a
Revert "remove UB"
WillAyd Dec 21, 2023
4647f12
merge fixup
WillAyd Dec 21, 2023
cba79f6
remove UB
WillAyd Dec 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
asan checks for datetime funcs
  • Loading branch information
WillAyd committed Sep 14, 2023
commit 663d6d44c1aeb08e55fd4595217837f35dd3fe95
2 changes: 1 addition & 1 deletion pandas/_libs/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def _test_parse_iso8601(ts: str):
obj = _TSObject()

string_to_dts(ts, &obj.dts, &out_bestunit, &out_local, &out_tzoffset, True)
check_dts_bounds(&obj.dts, NPY_FR_ns)
obj.value = npy_datetimestruct_to_datetime(NPY_FR_ns, &obj.dts)
check_dts_bounds(&obj.dts)
if out_local == 1:
obj.tzinfo = timezone(timedelta(minutes=out_tzoffset))
obj.value = tz_localize_to_utc_single(obj.value, obj.tzinfo)
Expand Down
3 changes: 2 additions & 1 deletion pandas/_libs/tslibs/conversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,14 @@ cdef _TSObject convert_datetime_to_tsobject(
if nanos:
obj.dts.ps = nanos * 1000

check_dts_bounds(&obj.dts, reso)
obj.value = npy_datetimestruct_to_datetime(reso, &obj.dts)

if obj.tzinfo is not None and not is_utc(obj.tzinfo):
offset = get_utcoffset(obj.tzinfo, ts)
pps = periods_per_second(reso)
obj.value -= int(offset.total_seconds() * pps)

check_dts_bounds(&obj.dts, reso)
check_overflows(obj, reso)
return obj

Expand Down Expand Up @@ -434,6 +434,7 @@ cdef _TSObject _create_tsobject_tz_using_offset(npy_datetimestruct dts,
datetime dt
Py_ssize_t pos

check_dts_bounds(&dts, reso)
value = npy_datetimestruct_to_datetime(reso, &dts)
obj.dts = dts
obj.tzinfo = timezone(timedelta(minutes=tzoffset))
Expand Down
2 changes: 2 additions & 0 deletions pandas/_libs/tslibs/np_datetime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ cdef int64_t pydatetime_to_dt64(datetime val,
Note we are assuming that the datetime object is timezone-naive.
"""
pydatetime_to_dtstruct(val, dts)
check_dts_bounds(dts, reso)
return npy_datetimestruct_to_datetime(reso, dts)


Expand All @@ -282,6 +283,7 @@ cdef int64_t pydate_to_dt64(
date val, npy_datetimestruct *dts, NPY_DATETIMEUNIT reso=NPY_FR_ns
):
pydate_to_dtstruct(val, dts)
check_dts_bounds(dts, reso)
return npy_datetimestruct_to_datetime(reso, dts)


Expand Down
9 changes: 9 additions & 0 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ from pandas._libs.tslibs.nattype cimport (
)
from pandas._libs.tslibs.np_datetime cimport (
NPY_DATETIMEUNIT,
check_dts_bounds,
get_unit_from_dtype,
import_pandas_datetime,
npy_datetimestruct,
Expand Down Expand Up @@ -3093,6 +3094,8 @@ cdef class SemiMonthOffset(SingleConstructorOffset):
days_in_month = get_days_in_month(dts.year, dts.month)
dts.day = min(to_day, days_in_month)

with gil:
check_dts_bounds(&dts, reso)
res_val = npy_datetimestruct_to_datetime(reso, &dts)

# Analogous to: out[i] = res_val
Expand Down Expand Up @@ -4762,6 +4765,8 @@ cdef ndarray shift_quarters(
dts.month = month_add_months(dts, modby * n - months_since)
dts.day = get_day_of_month(&dts, day_opt)

with gil:
check_dts_bounds(&dts, reso)
res_val = npy_datetimestruct_to_datetime(reso, &dts)

# Analogous to: out[i] = res_val
Expand Down Expand Up @@ -4820,6 +4825,8 @@ def shift_months(
dts.month = month_add_months(dts, months)

dts.day = min(dts.day, get_days_in_month(dts.year, dts.month))
with gil:
check_dts_bounds(&dts, reso)
res_val = npy_datetimestruct_to_datetime(reso, &dts)

# Analogous to: out[i] = res_val
Expand All @@ -4846,6 +4853,8 @@ def shift_months(
dts.month = month_add_months(dts, months_to_roll)
dts.day = get_day_of_month(&dts, day_opt)

with gil:
check_dts_bounds(&dts, reso)
res_val = npy_datetimestruct_to_datetime(reso, &dts)

# Analogous to: out[i] = res_val
Expand Down
10 changes: 10 additions & 0 deletions pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,8 @@ cdef int64_t unix_date_from_ymd(int year, int month, int day) noexcept nogil:
npy_datetimestruct dts
int64_t unix_date

with gil:
check_dts_bounds(&dts, NPY_FR_D)
memset(&dts, 0, sizeof(npy_datetimestruct))
dts.year = year
dts.month = month
Expand All @@ -738,6 +740,8 @@ cdef int64_t dts_to_year_ordinal(npy_datetimestruct *dts, int to_end) noexcept n
cdef:
int64_t result

with gil:
check_dts_bounds(dts, NPY_DATETIMEUNIT.NPY_FR_Y)
result = npy_datetimestruct_to_datetime(NPY_DATETIMEUNIT.NPY_FR_Y, dts)
if dts.month > to_end:
return result + 1
Expand Down Expand Up @@ -795,14 +799,20 @@ cdef int64_t get_period_ordinal(npy_datetimestruct *dts, int freq) noexcept nogi
return dts_to_qtr_ordinal(dts, fmonth)

elif freq_group == FR_WK:
with gil:
check_dts_bounds(dts, NPY_FR_D)
unix_date = npy_datetimestruct_to_datetime(NPY_FR_D, dts)
return unix_date_to_week(unix_date, freq - FR_WK)

elif freq == FR_BUS:
with gil:
check_dts_bounds(dts, NPY_FR_D)
unix_date = npy_datetimestruct_to_datetime(NPY_FR_D, dts)
return DtoB(dts, 0, unix_date)

unit = freq_group_code_to_npy_unit(freq)
with gil:
check_dts_bounds(dts, unit)
return npy_datetimestruct_to_datetime(unit, dts)


Expand Down
2 changes: 2 additions & 0 deletions pandas/_libs/tslibs/strptime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def array_strptime(
if string_to_dts_succeeded:
# No error reported by string_to_dts, pick back up
# where we left off
check_dts_bounds(&dts, NPY_FR_ns)
value = npy_datetimestruct_to_datetime(NPY_FR_ns, &dts)
if out_local == 1:
# Store the out_tzoffset in seconds
Expand Down Expand Up @@ -513,6 +514,7 @@ def array_strptime(
dts.us = us
dts.ps = ns * 1000

check_dts_bounds(&dts, NPY_FR_ns)
iresult[i] = npy_datetimestruct_to_datetime(NPY_FR_ns, &dts)
check_dts_bounds(&dts)

Expand Down
1 change: 1 addition & 0 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ cdef class _Timestamp(ABCTimestamp):

if own_tz is not None and not is_utc(own_tz):
pydatetime_to_dtstruct(self, &dts)
check_dts_bounds(&dts, self._creso)
val = npy_datetimestruct_to_datetime(self._creso, &dts) + self.nanosecond
else:
val = self._value
Expand Down
0