Skip to content

TST: Add another test for segfault in C engine #18128

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 1 commit into from
Nov 6, 2017
Merged
Changes from all commits
Commits
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
15 changes: 12 additions & 3 deletions pandas/tests/io/parser/c_parser_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ def test_empty_header_read(count):
test_empty_header_read(count)

def test_parse_trim_buffers(self):
# This test is part of a bugfix for issue #13703. It attmepts to
# This test is part of a bugfix for issue #13703. It attempts to
# to stress the system memory allocator, to cause it to move the
# stream buffer and either let the OS reclaim the region, or let
# other memory requests of parser otherwise modify the contents
# of memory space, where it was formely located.
# of memory space, where it was formally located.
# This test is designed to cause a `segfault` with unpatched
# `tokenizer.c`. Sometimes the test fails on `segfault`, other
# times it fails due to memory corruption, which causes the
Expand Down Expand Up @@ -346,7 +346,7 @@ def test_parse_trim_buffers(self):

# Generate the expected output: manually create the dataframe
# by splitting by comma and repeating the `n_lines` times.
row = tuple(val_ if val_ else float("nan")
row = tuple(val_ if val_ else np.nan
for val_ in record_.split(","))
expected = pd.DataFrame([row for _ in range(n_lines)],
dtype=object, columns=None, index=None)
Expand All @@ -359,6 +359,15 @@ def test_parse_trim_buffers(self):
# Check for data corruption if there was no segfault
tm.assert_frame_equal(result, expected)

# This extra test was added to replicate the fault in gh-5291.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth making a different test for this?

Copy link
Member Author

@gfyoung gfyoung Nov 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the whole point was to check whether or not the encoding argument would make a difference (notice that the calls are nearly the same). That's why I added them as such.

# Force 'utf-8' encoding, so that `_string_convert` would take
# a different execution branch.
chunks_ = self.read_csv(StringIO(csv_data), header=None,
dtype=object, chunksize=chunksize,
encoding='utf_8')
result = pd.concat(chunks_, axis=0, ignore_index=True)
tm.assert_frame_equal(result, expected)

def test_internal_null_byte(self):
# see gh-14012
#
Expand Down