Skip to content
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

New version crashes R #343

Closed
waynelapierre opened this issue Sep 26, 2021 · 8 comments · Fixed by #345
Closed

New version crashes R #343

waynelapierre opened this issue Sep 26, 2021 · 8 comments · Fixed by #345
Labels

Comments

@waynelapierre
Copy link

waynelapierre commented Sep 26, 2021

The recent updated RPostgres crashes R when running a code that used to work (account information is not disclosed):

require(RPostgres)
wrds <- dbConnect(drv = Postgres(), 
                  host = "wrds-pgdata.wharton.upenn.edu",
                  port = 9737,
                  user = "username", 
                  password = "password", 
                  sslmode = "require",
                  dbname = "wrds")

My session information is as follows:

R version 4.0.5 (2021-03-31)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Fedora 34 (Workstation Edition)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libflexiblas.so.3.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RPostgres_1.4.0

loaded via a namespace (and not attached):
 [1] bit_4.0.4       compiler_4.0.5  ellipsis_0.3.2  hms_1.1.0      
 [5] DBI_1.1.1       tools_4.0.5     rstudioapi_0.13 Rcpp_1.0.7     
 [9] bit64_4.0.5     vctrs_0.3.8     blob_1.2.2      lifecycle_1.0.1
[13] pkgconfig_2.0.3 rlang_0.4.11   

I reverted to version 1.3.3 and it works again.

@krlmlr
Copy link
Member

krlmlr commented Sep 26, 2021

Thanks for the report, sorry for the trouble.

Can you try running from a shell, is there an output before the crash? Can you compile RPostgres from source to do a git bisect to understand what causes the crash?

@krlmlr krlmlr added the reprex label Sep 26, 2021
@krlmlr
Copy link
Member

krlmlr commented Sep 26, 2021

What does RPostgres:::client_version() show?

@waynelapierre
Copy link
Author

waynelapierre commented Sep 26, 2021

RPostgres:::client_version() generates 130004 for both 1.3.3 and 1.4.0.
When I run the code (in my thread above) with 1.4.0 in shell, I got this error message:

/usr/include/c++/11/bits/stl_vector.h:1045: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = const char*; _Alloc = std::allocator<const char*>; std::vector<_Tp, _Alloc>::reference = const char*&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]: Assertion '__n < this->size()' failed.
Aborted (core dumped)


@krlmlr
Copy link
Member

krlmlr commented Sep 26, 2021

Thanks, that helps.

Can you compile RPostgres from source to do a git bisect to understand what causes the crash? Rough instructions:

git clone https://github.com/r-dbi/RPostgres.git
cd RPostgres
git bisect bad v1.4.0
git bisect good v1.3.3
cp ... test.R
git bisect run R -q -f test.R

with test.R containing:

system("git clean -fdx")
pkgload::load_all()
dbConnect(...)

The process might run for ~1 hour, much faster if ccache is active.

Let me know if you need more info.

@krlmlr krlmlr added the bug label Sep 26, 2021
@krlmlr
Copy link
Member

krlmlr commented Sep 26, 2021

Looking at the changes to the C++ code since v1.3.3, I think I might have found the problem.

@krlmlr
Copy link
Member

krlmlr commented Sep 26, 2021

The first PR might fix the cause, the second PR the symptoms (but crash at the first query).

Can you please install with

remotes::install_github("r-dbi/RPostgres#345")

and test?

@waynelapierre
Copy link
Author

Problem solved. Thank God that I don't have to do the one-hour git bisect. Thank you for this great package and quick reply.

@krlmlr krlmlr removed the reprex label Sep 26, 2021
krlmlr added a commit that referenced this issue Sep 26, 2021
- Avoid crash by dereferencing 0-size vector (#343).
krlmlr added a commit that referenced this issue Oct 31, 2021
RPostgres 1.4.1

- Avoid crash by dereferencing 0-size vector (#343).
@github-actions
Copy link
Contributor

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants