# Problem with using CSV package when set \`limit\` option

**URL:** <https://discourse.julialang.org/t/problem-with-using-csv-package-when-set-limit-option/74724>\
**Category:** Data\
**Tags:** dataframes, csv\
**Created:** [January 17, 2022, 1:47am UTC](https://discourse.julialang.org/t/problem-with-using-csv-package-when-set-limit-option/74724 "2022-01-17T01:47:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xinchin](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xinchin](https://discourse.julialang.org/u/xinchin)\
**Post date:** [January 17, 2022, 1:47am UTC](https://discourse.julialang.org/t/problem-with-using-csv-package-when-set-limit-option/74724/1 "2022-01-17T01:47:01Z")

</div>

I get `ArgumentError: Reference array points beyond the end of the pool` when try to sort a data frame, now I know the problem is because I am using `CSV.jl`, but ideally this shouldn’t happen

A minimal example to show the problem

```julia
using DataFrames
using CSV
df = DataFrame(x = repeat(["a", "b"], 10^6), y = rand(2*10^6));
f1 = tempname();
CSV.write(f1, df);
df2 = CSV.read(f1, DataFrame, header = false, skipto = 1001, limit = 10000);
sort(df2, 1)
ERROR: ArgumentError: Reference array points beyond the end of the pool
[...]

```

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [January 17, 2022, 1:53am UTC](https://discourse.julialang.org/t/problem-with-using-csv-package-when-set-limit-option/74724/2 "2022-01-17T01:53:29Z")

</div>

I can’t replicate the problem. It works on my machine. Can you try the same code on 1.7 and the latest versions of both CSV/jl and DataFrames.jl? Maybe the problem has been fixed in more recent versions.

---

<div class="post-metadata">

**Author:** ![xinchin](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xinchin](https://discourse.julialang.org/u/xinchin)\
**Post date:** [January 17, 2022, 2:10am UTC](https://discourse.julialang.org/t/problem-with-using-csv-package-when-set-limit-option/74724/3 "2022-01-17T02:10:21Z")

</div>

reproducing the example may be tricky since the problem is because of using multiple core to read data, maybe need playing around with data and skipto and limit?

CSV.jl version is v0.9.11 and it cannot updated more than this (conflict with many other packages) and DataFrames is 1.3.2

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [January 17, 2022, 2:38am UTC](https://discourse.julialang.org/t/problem-with-using-csv-package-when-set-limit-option/74724/4 "2022-01-17T02:38:41Z")

</div>

Can you try in a new environment? And without multiple cores?

This is for debugging purposes to isolate the problem.

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [January 17, 2022, 7:04am UTC](https://discourse.julialang.org/t/problem-with-using-csv-package-when-set-limit-option/74724/5 "2022-01-17T07:04:15Z")

</div>

This is a bug in `SentinelArrays.ChainedVector` use in CSV.jl. I have opened [https://github.com/JuliaData/CSV.jl/issues/963](https://github.com/JuliaData/CSV.jl/issues/963).
