Skip to content

Only export relevant symbols to shared library. - #303

Merged
krlmlr merged 1 commit into
r-dbi:masterfrom
troels:hide-default-symbols
Dec 3, 2019
Merged

Only export relevant symbols to shared library.#303
krlmlr merged 1 commit into
r-dbi:masterfrom
troels:hide-default-symbols

Conversation

@troels

@troels troels commented Nov 25, 2019

Copy link
Copy Markdown
Contributor

Hi,

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

I get stacktraces 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 RSQLite's result_release collides with RPostgres' result_release in their respective shared libraries. The best way to fix that is probably to only export symbols from the shared library which will be needed by R.

So I suggest changing default symbol visibility to hidden, so the two libraries can coexist peacefully.

See here for more information:
RcppCore/Rcpp#720

@troels
troels force-pushed the hide-default-symbols branch 3 times, most recently from ea0ce88 to 335acaa Compare November 25, 2019 01:09
Currently the shared library are exporting all functions, some of
which collides with other DBI drivers, such as RPostgres.  Change
default symbol visibility to hidden and export only functions that
should be reachable from the R code, either via the R macro
attribute_visible (in C) or the Rcpp macro RcppExport (in C++).
@krlmlr
krlmlr merged commit 5181569 into r-dbi:master Dec 3, 2019
@krlmlr

krlmlr commented Dec 3, 2019

Copy link
Copy Markdown
Member

Thanks!

@troels
troels deleted the hide-default-symbols branch December 4, 2019 06:44
@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.

2 participants