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

Hide unused symbols in shared library #230

Merged
merged 2 commits into from
Dec 3, 2019

Conversation

troels
Copy link
Contributor

@troels troels commented Nov 27, 2019

Hi,

I have problems using RPostgres and RSQLite from the same R-process.

I get stacktraces from R such as these:

 *** caught segfault ***
address 0x1000000010, cause 'memory not mapped'

Traceback:
 1: result_release(res@ptr)
 2: dbClearResult(rs)
 3: dbClearResult(rs)
 4: dbExecute(con, "SET TIMEZONE='UTC'")
 5: dbExecute(con, "SET TIMEZONE='UTC'")
 6: .local(drv, ...)
 7: DBI::dbConnect(RPostgres::Postgres(), dbname = "kingfisher")
 8: DBI::dbConnect(RPostgres::Postgres(), dbname = "kingfisher")
 9: eval(expr)
10: eval(expr)
11: create_connection(production = production)
12: load_list_of_tables("ensembl", tables, production = production)
An irrecoverable exception occurred. R is aborting now ...
bin/load_ensembl.sh: line 7: 36907 Segmentation fault      (core dumped) Rscript R/load_ensembl.R

After wading through the code with gdb it appears that RPostgres and RSQLite export a number of symbols named the same, which are then randomly assigned to the first loaded of the libraries, leading to crashes, stack corruption and other nastiness.

I therefore suggest changing default symbol visibility to hidden, so the two libraries can coexist peacefully. A number of other mysterious issues, might also be consequences of this symbol conflict.

I created a corresponding pull request for RSQlite: r-dbi/RSQLite#303

See here for more information:
RcppCore/Rcpp#720

@troels troels changed the title Hide symbols in shared library that are not Hide unused symbols in shared library Nov 27, 2019
Exported symbols from the shared library may
conflict with other shared libraries. Especially
other DBI drivers. To avoid symbol collision, hide
symbols that shouldn't be exported.
@krlmlr krlmlr changed the title Hide unused symbols in shared library Hide unused symbols in shared library Dec 3, 2019
@krlmlr krlmlr merged commit 41d21ec into r-dbi:master Dec 3, 2019
@@ -58,6 +58,7 @@ addons:
- libpq-dev
- libmagick++-dev
- libssh2-1-dev
- devscripts
Copy link
Member

Choose a reason for hiding this comment

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

I wonder what this is for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @krlmlr

It's for the script checkbashisms, which is required by "R CMD check" in R-devel now.

@krlmlr
Copy link
Member

krlmlr commented Dec 3, 2019

Thanks for the PRs. Does this problem also affect {RMariaDB} and {odbc}?

@troels
Copy link
Contributor Author

troels commented Dec 4, 2019

Yeah, odbc and RMariaDB would benefit from similar patches too. I might be able to get to it in the next few days, if I can find a little free time.

@troels troels deleted the hide-default-symbols branch December 4, 2019 06:43
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants