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

UBSAN issue with sanitizers #229

Closed
paciorek opened this issue Sep 12, 2016 · 34 comments
Closed

UBSAN issue with sanitizers #229

paciorek opened this issue Sep 12, 2016 · 34 comments

Comments

@paciorek
Copy link
Contributor

CRAN folks noted that we have another problem that we hadn't noticed on our page of checking results for nimble:
https://cran.r-project.org/web/checks/check_results_nimble.html

Memtest notes: clang-UBSAN
See: https://www.stats.ox.ac.uk/pub/bdr/memtests/clang-UBSAN/nimble-Ex.Rout

search for "runtime error" and you'll see an issue with compilation of our nfVar() example.

This post from Dirk seems useful and I will try to run his test on 0.6-1 in his docker container and see what I discover.
https://www.r-bloggers.com/running-ubsan-tests-via-clang-with-rocker/

Note that issue #228 is also revealed in the checking of nimble's examples... Not sure if CRAN will insist we fix that.

@perrydv
Copy link
Contributor

perrydv commented Sep 12, 2016

The error reported is:
RcppUtils.cpp:1044:20: runtime error: member call on address 0x60d000002018 which does not point to an object of type 'NimArrType'
0x60d000002018: note: object is of type 'NimArr<2, double>'

But NimArrType is a base class to NimArr<2, double>, and the call is to a virtual member function. So it is complaining about a call to a base class virtual member function via a base class pointer that actually points to a derived class, as it should. Should be ok, and the code has worked for a long time and is used a lot in the system.

It looks like a bit of work to set up Dirk’s docker image for re-creating the AddressSanitizer result. If you get it working I could try to exploring more.

Or, can we just remove the @example (or set it to not run) and move on? I think this is a non-issue.

@paciorek
Copy link
Contributor Author

I don't know how CRAN will react if we simply remove the @example. And I'm also not sure if they will balk at the warning related to issue #228, which also shows up in the output from our examples when run under R-devel.

I suppose I could email Kurt back and ask for the configuration they are using to try to replicate this.

More info on the address sanitizer is here
https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Using-Address-Sanitizer

I tried putting this in .R/Makevars:
CC = gcc -std=gnu99 -fsanitize=address -fno-omit-frame-pointer
CXX = g++ -fsanitize=address -fno-omit-frame-pointer
F77 = gfortran -fsanitize=address
FC = gfortran -fsanitize=address

But now I get this error with the nfVar example instead:

 Cnf2 <- compileNimble(nf2)

compiling... this may take a minute. Use nimbleOptions(showCompilerOutput = TRUE) to see C++ compiler details.
Error in dyn.load(getSOName(name, dirName), local = TRUE) :
unable to load shared object '/tmp/RtmpDAEwhh/nimble_generatedCode/P_1_nfRefClass_R_GlobalEnv8109_12_19_39_52.so':
/tmp/RtmpDAEwhh/nimble_generatedCode/P_1_nfRefClass_R_GlobalEnv8109_12_19_39_52.so: undefined symbol: __asan_report_load8
Cnf2$run()

More generally when I add the "-fsanitize=undefined" (this seems to correspond to the UBSAN checking) I also get an error in loading our .so's (the nfVar example or more generally in trying to compileNimble or even load the nimble package) with a similar error to the above:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/tmp/nim061/nimble/libs/nimble.so':
/tmp/nim061/nimble/libs/nimble.so: undefined symbol: __ubsan_handle_type_mismatch

I can't figure out Dirk's docker container. It seems to be advertized as using clang, but when I run it, it seems to use gcc. Plus it doesn't seem to be doing the address/ubsan checking - NIMBLE installs fine and the nfVar example is fine.

@paciorek
Copy link
Contributor Author

The undefined symbols might be because R has to be built with certain -f flags related to the address/ubsan stuff. I'll monkey around with that a bit more.

@cboettig
Copy link

Hey @paciorek , just to double check, you are using RD to run the devel version of R on Dirk's ubsan container, and not R (which just runs the R version from r-base, not the devel version built with UBSAN)? And are you using the check.r script from littler?

(apologies for the out-of-the-blue comment, I don't normally pay attention to any nimble issues but I do work with Dirk on rocker images; though admittedly ubsan containers are entirely his baby)

@pistacliffcho
Copy link
Contributor

I don't know how CRAN will react if we simply remove the @example
https://github.com/example.

My experience thus far with CRAN is that they will not care: there are
simply way too many R-packages coming through CRAN at any given moment that
they cannot track anything other than what the latest automated warnings
are. Perhaps Duncan's involvement in the project may change things, but
basically they check that R CMD check --as-cran under R-devel has no errors
or warnings (on all systems) and run it through valgrind. No flags no
problem.

I've had a surprisingly high amount of support from them when there is a
problem though (which is extra incentive to not have any problems if you
have any respect for CRAN).

And I'm also not sure if they will balk at the warning related to issue
#228 #228, which also shows up
in the output from our examples when run under R-devel.

Under normal circumstances, they certainly would.

On Tue, Sep 13, 2016 at 8:30 AM, Christopher Paciorek <
[email protected]> wrote:

The undefined symbols might be because R has to be built with certain -f
flags related to the address/ubsan stuff. I'll monkey around with that a
bit more.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#229 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF64k8okEVtXh6pAUaUq9W71rGcQ-F_8ks5qpsGbgaJpZM4J6-Ip
.

@perrydv
Copy link
Contributor

perrydv commented Sep 13, 2016

The undefined symbol looks like something from the addressSanitizer that is getting lost in nimble's on-the-fly compilation.

I am trying to create, outside of R, a boiled down case of the class hierarchy and compilation scheme involved and see if I can re-create it that way.

@paciorek if you want to keep pushing on re-creating CRAN's result, I suspect we need those flags in src/Makevars and inst/make/Makevars.in, so they will be picked up in both package building and on-the-fly compilation.

Thanks @pistacliffcho. I think it is worth giving this some further attention but then planning to just remove it from the example in the Rd. We can include a note to CRAN.

@perrydv
Copy link
Contributor

perrydv commented Sep 13, 2016

So here is what I suspect is going on:

It may be an issue created by nimble.so and libnimble.a having some of the same code compiled into them, which is for simplicity in our build process but does create some duplication in binary libraries. I think a pointer to an object of a derived class (NimArr<2, double>) created in code linked against libnimble.a is then being passed as a void* (since R external pointers end up cast to void*) into a function in nimble.so (not libnimble.a) that casts it back to something meaningful and uses it. But it casts it to a base class pointer, and everything should be completely identical to what is in libnimble.a, but it may not be recognized by the address sanitizer as part of the same class hierarchy since they are compiled twice and appear in binary libraries redundantly. We have never had a problem from this.

This guess at what's happening could be wrong. If it's right, it involves some of the same C++ code organization issues around the CRAN system that we've had challenges with before. I'll think about if there are easy workarounds, but just dropping the example still seems like a good path.

@paciorek
Copy link
Contributor Author

Thanks, @cboettig ! I hadn't realized RD was there and was very confused about the container being for clang+Rdevel but not seeing R-devel with clang there.

I'm still not sure how to run check.r such that it uses RD rather than R. Can you clarify?

@paciorek
Copy link
Contributor Author

@pistacliffcho when you say run through valgrind, I'm not sure how that is related to the memtest UBSAN thing. Do you know how they do the valgrind checking?

@pistacliffcho
Copy link
Contributor

I wasn't specifically referring to memtest UBSAN, but just in general the
testing that they appear to do.

My understanding of they do is just something like this:

R -d valgrind --vanilla < mypkg-Ex.R
R -d "valgrind --tool=memcheck --leak-check=full" --vanilla < mypkg-Ex.R

(example lifted from Writing R Extensions 4.3.2). I had a conversation with
Ripley in which he looked through the valgrind output produced by the code
above. I don't think they run it all the time, but it does seem to be run
some times. Interestingly, he found an out of bounds error that would never
be a problem; basically something like:

if(c_vector[i] > 0 && i < c_vector.size() ) {...}
// error is that you could read past the last element, but doing so always
produces false!

I'm not a valgrind expert at all, but I have heard that it runs much
better on Linux than Mac OS. And the output from the code above is much
messier on my mac than what Ripley sends me, so I suspect it is less of a
headache to use Linux and valgrind.

On Tue, Sep 13, 2016 at 11:42 AM, Christopher Paciorek <
[email protected]> wrote:

@pistacliffcho https://github.com/pistacliffcho when you say run
through valgrind, I'm not sure how that is related to the memtest UBSAN
thing. Do you know how they do the valgrind checking?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#229 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF64k68cU-AjW85uszIrl4vKukox2u3kks5qpu6ggaJpZM4J6-Ip
.

@perrydv
Copy link
Contributor

perrydv commented Sep 13, 2016

I haven't proven if it's the double compilation, but it's still my best guess, and I have confirmed that a derived object created from one compilation is being handled in code from the other, which is as expected. If we want to address this underlying issue, I think it would take some careful following of threads about which functions are called in which contexts and could be separated into only libnimble and kept out of nimble.so and called via R's dll information so that when multiple projects are compiled we only use the utility functions built (redundantly) into that compilation unit. This has been on the to-do list for a while and would be a good idea, but since things haven't been breaking, it hasn't been the top priority.

@paciorek
Copy link
Contributor Author

I asked Kurt H for more info on reproducing how CRAN is generating the
memtest-UBSAN output as I can build R-devel with clang with the
-fsanitize=undefined but not with -fsanitize=address so I can't replicate
the error CRAN is seeing.

Let's see what I hear and then make a decision about simply removing ?nfVar.

On Tue, Sep 13, 2016 at 1:40 PM, perrydv [email protected] wrote:

I haven't proven if it's the double compilation, but it's still my best
guess, and I have confirmed that a derived object created from one
compilation is being handled in code from the other, which is as expected.
If we want to address this underlying issue, I think it would take some
careful following of threads about which functions are called in which
contexts and could be separated into only libnimble and kept out of
nimble.so and called via R's dll information so that when multiple projects
are compiled we only use the utility functions built (redundantly) into
that compilation unit. This has been on the to-do list for a while and
would be a good idea, but since things haven't been breaking, it hasn't
been the top priority.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#229 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACYr3nFTSZVkuN4AmRpzNrucOfxpMeg_ks5qpwo6gaJpZM4J6-Ip
.

@perrydv
Copy link
Contributor

perrydv commented Sep 13, 2016

I think I've fixed the situation for the particular cpp function in question. Questions are: Am I right about the underlying problem, since we haven't been able to reproduce it in the first place? And how much pre-emptive modifications of other functions in similar compilation situations is worth it? I'm going to start looking at some other cases.

@paciorek
Copy link
Contributor Author

Ok, hopefully we get more info from Kurt and then we can reproduce the original error and see if this fixes it. If we don't get more info or still can't reproduce the original error, then I think we can say we've done our due diligence with the -fsanitize=undefined and just resubmit.

@paciorek
Copy link
Contributor Author

here's the configuration info from Kurt, so it's basically what I've been trying but I was using an older clang. clang-3.9 is not available via an ubuntu package so I may try to test with clang-3.8 instead.

Perry, what branch has your fix to the cpp function used in the nfVar example?

====== from Kurt H. ========================

On Debian testing I configure with

CC="clang-3.9 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer"

and similarly for CXX. Not sure about clang-3.5, in general you'd want
gcc-6 and clang-3.9 if possible for ASAN and UBSAN diagnostics.

The .Rout file at
https://www.stats.ox.ac.uk/pub/bdr/memtests/clang-UBSAN/nimble-Ex.Rout
is obtained by running the examples with a *SAN enhanced build, which
apparently finds

RcppUtils.cpp:1044:20: runtime error: member call on address 0x60d000002018 which does not point to an object of type 'NimArrType'
0x60d000002018: note: object is of type 'NimArr<2, double>'
00 40 8f 40 a0 66 e8 ba 73 7f 00 00 02 00 00 00 be be be be 00 00 00 00 00 00 00 00 28 20 00 00
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'NimArr<2, double>'
SUMMARY: AddressSanitizer: undefined-behavior RcppUtils.cpp:1044:20 in

@perrydv
Copy link
Contributor

perrydv commented Sep 14, 2016

compilation_overlaps

At the moment it has some other changes and it outputs some diagnostic messages. I've made more progress isolating use of some functions just to nimble.so or libnimble. Partly this is pre-emptive against further addressSanitizer risks, and partly it is because it is a good idea anyway.

@paciorek
Copy link
Contributor Author

For future ref, here's what seems to work to build R-devel with *SAN support:

./configure --prefix=/usr/local/R-devel_2016-09-12-clang38 'CC=clang-3.8 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer' 'MAIN_LDFLAGS=-fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer' 'CFLAGS=-pipe -std=gnu99 -Wall -pedantic -g' 'F77=gfortran' 'FFLAGS=-pipe -Wall -pedantic -g' 'CXX=clang++-3.8 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer' 'CXXFLAGS=-pipe -Wall -pedantic -g' 'CXX1X=clang++-3.8 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer' 'FC=gfortran' 'FCFLAGS=-pipe -Wall -pedantic -g' --with-cairo --with-jpeglib --with-readline --with-tcltk --with-lapack --enable-R-profiling --enable-R-shlib

Also note to self - need to turn vm.overcommit_memory to 2 on my Linux box or building R will fail because conftest will not run as ASAN tries to allocate a ridiculous amount of memory.

@paciorek
Copy link
Contributor Author

paciorek commented Sep 16, 2016

I'm getting this when I run R CMD check (without the *SAN business) on nimble_0.6-1.tar.gz from compilation_overlaps.

* checking foreign function calls ... NOTE
Registration problems:
  Evaluating ‘getNativeSymbolInfo("setDoublePtrFromSinglePtr", dll)’ during check gives error
‘object 'dll' not found’:
   .Call(getNativeSymbolInfo("setDoublePtrFromSinglePtr", dll), 
       elementPtr, value)
  Evaluating ‘getNativeSymbolInfo("SEXP_2_Nim", dll)’ during check gives error
‘object 'dll' not found’:
   .Call(getNativeSymbolInfo("SEXP_2_Nim", dll), elementPtr, as.integer(pointDepth), 
       values, allowResize)
  Evaluating ‘getNativeSymbolInfo("setOnePtrVectorOfPtrs", dll)’ during check gives error
‘object 'dll' not found’:
   .Call(getNativeSymbolInfo("setOnePtrVectorOfPtrs", dll), accessorPtr, 
       as.integer(i - 1), contentsPtr)
  Evaluating ‘getNativeSymbolInfo("setPtrVectorOfPtrs", dll)’ during check gives error
‘object 'dll' not found’:
   .Call(getNativeSymbolInfo("setPtrVectorOfPtrs", dll), accessorPtr, 
       contentsPtr, as.integer(length))

Not sure if compilation_overlaps is obsolete - I was hoping to test just the nfVar fix...

@paciorek
Copy link
Contributor Author

Ok, well, I have R-devel built with clang-3.8 with ASAN and UBSAN checking working in Ubuntu but it's not reproducing the clang-UBSAN error for nfVar reported by CRAN. Frustrating. Perhaps because CRAN may be using clang-3.9 but that feels a bit unlikely.

@paciorek
Copy link
Contributor Author

R-devel CMD check on compilation_overlaps with ASAN/UBSAN checking is giving the following.

I'm also filing a separate note on R-devel CMD check on compilation_overlaps3.

makeNimbleFxnCppCopyTypes: Error while checking: C stack usage 8011696
is too close to the limit

==13564==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1368 byte(s) in 3 object(s) allocated from:
#0 0x4c3bc8 (/usr/local/R-devel_2016-09-12-clang38/lib64/R/bin/exec/R+0x4c3bc8)
#1 0x7fc447c38ca4 (/usr/local/R-devel_2016-09-12-clang38/lib64/R/modules//internet.so+0x72ca4)
#2 0x7fc452896bed (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xdd6bed)
#3 0x7fc4523b207e (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0x8f207e)
#4 0x7fc4526dfa19 (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1fa19)
#5 0x7fc4526afcee (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
...
Direct leak of 912 byte(s) in 2 object(s) allocated from:
#0 0x4c3bc8 (/usr/local/R-devel_2016-09-12-clang38/lib64/R/bin/exec/R+0x4c3bc8)
#1 0x7fc447c2c6e4 (/usr/local/R-devel_2016-09-12-clang38/lib64/R/modules//internet.so+0x666e4)
#2 0x7fc452893eba (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xdd3eba)
#3 0x7fc4523b2117 (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0x8f2117)
#4 0x7fc4526dfa19 (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1fa19)
#5 0x7fc4526afcee (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
#6 0x7fc45276f30c (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
...
SUMMARY: AddressSanitizer: 3192 byte(s) leaked in 7 allocation(s).

@paciorek
Copy link
Contributor Author

paciorek commented Sep 16, 2016

here's what I get running R-devel with clang and *SAN checking on compilation_overlaps3:

* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking whether package ‘nimble’ can be installed ... ERROR
Installation failed.
See ‘/var/tmp/paciorek/nimble-dev/nimble/packages/nimble.Rcheck/00install.out’ for details.
* DONE

Status: 1 ERROR, 1 NOTE
See
  ‘/var/tmp/paciorek/nimble-dev/nimble/packages/nimble.Rcheck/00check.log’
for details.


=================================================================
==10005==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1368 byte(s) in 3 object(s) allocated from:
    #0 0x4c3bc8  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/bin/exec/R+0x4c3bc8)
    #1 0x7f4e07848ca4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/modules//internet.so+0x72ca4)
    #2 0x7f4e124abbed  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xdd6bed)
    #3 0x7f4e11fc707e  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0x8f207e)
    #4 0x7f4e122f4a19  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1fa19)
    #5 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #6 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #7 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #8 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #9 0x7f4e1237d123  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xca8123)
    #10 0x7f4e123cd1e2  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcf81e2)
    #11 0x7f4e123cd702  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcf8702)
    #12 0x7f4e122db496  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc06496)
    #13 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #14 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #15 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #16 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #17 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #18 0x7f4e123897e3  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcb47e3)
    #19 0x7f4e11d6c94d  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0x69794d)
    #20 0x7f4e1257ac04  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xea5c04)
    #21 0x7f4e122f5e63  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc20e63)
    #22 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #23 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #24 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #25 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #26 0x7f4e1237d123  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xca8123)
    #27 0x7f4e123cd1e2  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcf81e2)
    #28 0x7f4e123cd702  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcf8702)
    #29 0x7f4e122db496  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc06496)

Direct leak of 912 byte(s) in 2 object(s) allocated from:
    #0 0x4c3bc8  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/bin/exec/R+0x4c3bc8)
    #1 0x7f4e0783c6e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/modules//internet.so+0x666e4)
    #2 0x7f4e124a8eba  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xdd3eba)
    #3 0x7f4e11fc7117  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0x8f2117)
    #4 0x7f4e122f4a19  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1fa19)
    #5 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #6 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #7 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #8 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #9 0x7f4e1237d123  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xca8123)
    #10 0x7f4e123cd1e2  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcf81e2)
    #11 0x7f4e123cd702  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcf8702)
    #12 0x7f4e122db496  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc06496)
    #13 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #14 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #15 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #16 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #17 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #18 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #19 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #20 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #21 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #22 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #23 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #24 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #25 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #26 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #27 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #28 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #29 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)

Direct leak of 456 byte(s) in 1 object(s) allocated from:
    #0 0x4c3bc8  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/bin/exec/R+0x4c3bc8)
    #1 0x7f4e0783c6e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/modules//internet.so+0x666e4)
    #2 0x7f4e124a8eba  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xdd3eba)
    #3 0x7f4e11fc7117  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0x8f2117)
    #4 0x7f4e122f4a19  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1fa19)
    #5 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #6 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #7 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #8 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #9 0x7f4e1237d123  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xca8123)
    #10 0x7f4e123cd1e2  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcf81e2)
    #11 0x7f4e123cd702  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcf8702)
    #12 0x7f4e122db496  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc06496)
    #13 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #14 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #15 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #16 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #17 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #18 0x7f4e123897e3  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcb47e3)
    #19 0x7f4e11d6c94d  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0x69794d)
    #20 0x7f4e1257ac04  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xea5c04)
    #21 0x7f4e122f5e63  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc20e63)
    #22 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #23 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #24 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #25 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #26 0x7f4e1237d123  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xca8123)
    #27 0x7f4e123cd1e2  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcf81e2)
    #28 0x7f4e123cd702  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcf8702)
    #29 0x7f4e122db496  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc06496)

Direct leak of 456 byte(s) in 1 object(s) allocated from:
    #0 0x4c3bc8  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/bin/exec/R+0x4c3bc8)
    #1 0x7f4e0783c6e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/modules//internet.so+0x666e4)
    #2 0x7f4e124a8eba  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xdd3eba)
    #3 0x7f4e11fc7117  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0x8f2117)
    #4 0x7f4e122f4a19  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1fa19)
    #5 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #6 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #7 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #8 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #9 0x7f4e1237d123  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xca8123)
    #10 0x7f4e123cd1e2  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcf81e2)
    #11 0x7f4e123cd702  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcf8702)
    #12 0x7f4e122db496  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc06496)
    #13 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #14 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #15 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #16 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #17 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #18 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #19 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #20 0x7f4e1237d123  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xca8123)
    #21 0x7f4e123cd1e2  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcf81e2)
    #22 0x7f4e123cd702  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcf8702)
    #23 0x7f4e122db496  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc06496)
    #24 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #25 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #26 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)
    #27 0x7f4e122c4cee  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xbefcee)
    #28 0x7f4e1238430c  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xcaf30c)
    #29 0x7f4e122f29e4  (/usr/local/R-devel_2016-09-12-clang38/lib64/R/lib/libR.so+0xc1d9e4)

SUMMARY: AddressSanitizer: 3192 byte(s) leaked in 7 allocation(s).

==========/var/tmp/paciorek/nimble-dev/nimble/packages/nimble.Rcheck/00install.out===========

* installing *source* package ‘nimble’ ...
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
working on eigen
checking how to run the C++ preprocessor... clang++-3.8 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -
fno-omit-frame-pointer -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking Eigen/Dense usability... no
checking Eigen/Dense presence... no
checking for Eigen/Dense... no
Using the version of Eigen provided with NIMBLE
NIMBLE_DIR = /var/tmp/paciorek/nimble-dev/nimble/packages/nimble.Rcheck/nimble
ENABLE_LIB=true
configure: creating ./config.status
config.status: creating inst/make/Makevars
config.status: creating inst/make/Makevars_lib
config.status: creating R/config.R
config.status: creating src/Makevars
Building libnimble
clang++-3.8 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer  -I/usr/local/R-devel_2016-09-12-clang38/lib64/R/include -DNDEBUG -I"../include" -I/usr/local/include    -fpic  -pipe -Wall -pedantic -g  -c RcppUtils.cpp -o RcppUtils.o
clang++-3.8 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer  -I/usr/local/R-devel_2016-09-12-clang38/lib64/R/include -DNDEBUG -I"../include" -I/usr/local/include    -fpic  -pipe -Wall -pedantic -g  -c RcppNimbleUtils.cpp -o RcppNimbleUtils.o
clang++-3.8 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer  -I/usr/local/R-devel_2016-09-12-clang38/lib64/R/include -DNDEBUG -I"../include" -I/usr/local/include    -fpic  -pipe -Wall -pedantic -g  -c Utils.cpp -o Utils.o
clang++-3.8 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer  -I/usr/local/R-devel_2016-09-12-clang38/lib64/R/include -DNDEBUG -I"../include" -I/usr/local/include    -fpic  -pipe -Wall -pedantic -g  -c NamedObjects.cpp -o NamedObjects.o
clang++-3.8 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer  -I/usr/local/R-devel_2016-09-12-clang38/lib64/R/include -DNDEBUG -I"../include" -I/usr/local/include    -fpic  -pipe -Wall -pedantic -g  -c ModelClassUtils.cpp -o ModelClassUtils.o
clang++-3.8 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer  -I/usr/local/R-devel_2016-09-12-clang38/lib64/R/include -DNDEBUG -I"../include" -I/usr/local/include    -fpic  -pipe -Wall -pedantic -g  -c accessorClasses.cpp -o accessorClasses.o
clang++-3.8 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer  -I/usr/local/R-devel_2016-09-12-clang38/lib64/R/include -DNDEBUG -I"../include" -I/usr/local/include    -fpic  -pipe -Wall -pedantic -g  -c accessorClasses.cpp -o accessorClasses.o
clang++-3.8 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer  -I/usr/local/R-devel_2016-09-12-clang38/lib64/R/include -DNDEBUG -I"../include" -I/usr/local/include    -fpic  -pipe -Wall -pedantic -g  -c dists.cpp -o dists.o
clang++-3.8 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer  -I/usr/local/R-devel_2016-09-12-clang38/lib64/R/include -DNDEBUG -I"../include" -I/usr/local/include    -fpic  -pipe -Wall -pedantic -g  -c nimDists.cpp -o nimDists.o
clang++-3.8 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer  -I/usr/local/R-devel_2016-09-12-clang38/lib64/R/include -DNDEBUG -I"../include" -I/usr/local/include    -fpic  -pipe -Wall -pedantic -g  -c nimbleGraph.cpp -o nimbleGraph.o
linking libnimble.so
Linux   
clang++-3.8 -fsanitize=undefined,address -fno-sanitize=float-divide-by-zero,vptr -fno-omit-frame-pointer  -shared -o libnimble.so  RcppUtils.o RcppNimbleUtils.o Utils.o NamedObjects.o ModelClassUtils.o accessorClasses.o dists.o nimDists.o nimbleGraph.o 
accessorClasses.o: In function `__cxx_global_var_init.13':
/var/tmp/paciorek/nimble-dev/nimble/packages/nimble.Rcheck/00_pkg_src/nimble/inst/CppCode/accessorClasses.cpp:21: multiple definition of `_NIMBLE_WHITESPACE'
RcppUtils.o:/var/tmp/paciorek/nimble-dev/nimble/packages/nimble.Rcheck/00_pkg_src/nimble/inst/CppCode/RcppUtils.cpp:10: first defined here
accessorClasses.o: In function `__cxx_global_var_init.14':
/var/tmp/paciorek/nimble-dev/nimble/packages/nimble.Rcheck/00_pkg_src/nimble/inst/CppCode/accessorClasses.cpp:21: multiple definition of `_NIMBLE_WHITESPACEBRACKET'
RcppUtils.o:/var/tmp/paciorek/nimble-dev/nimble/packages/nimble.Rcheck/00_pkg_src/nimble/inst/CppCode/RcppUtils.cpp:10: first defined here
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libnimble.so] Error 1
ERROR: configuration failed for package ‘nimble’
* removing ‘/var/tmp/paciorek/nimble-dev/nimble/packages/nimble.Rcheck/nimble’

=====================

@perrydv
Copy link
Contributor

perrydv commented Sep 16, 2016

No, compiler_overlaps3 isn't supposed to work yet.

I'm not sure what the status of compiler_overlaps was for the version you had.

I suspect all the warnings of memory leaks from the sanitizer checks are for similar reasons that I suspect (but we can't confirm) for the first address sanitizer warning we saw: In some cases we have relied on duplicate compilations of exactly the same code and counted on the ability to instantiate an object from one compilation unit and then pass a pointer to it to a function in the other compilation unit and have that function use the pointed-to class correctly because both were compiled identically. It's annoying to do it this way but we've never had a problem. It was essentially a workaround to the difficulty of building and distributing a so/dll via CRAN that our on-the-fly compilation could link to.

The message about the C stack usage being too close to the limit is from a pure R function that is not doing anything with our compiled code, so on first glance it would seem to involve R itself and not our compiled code.

Does CRAN actually run the LeakSanitizer? That output does not easily reveal what is at issue, and I have no way to know if it can see R and objects from our compiled code interacting, such as if R has an external pointer to an object from our compiled code.

@paciorek
Copy link
Contributor Author

Yeah, not clear on what CRAN runs (Kurt indicated both ASAN and UBSAN but the naming of the testing that we failed was clang-UBSAN).

And if they do run LeakSanitizer, which seems to be the case, why didn't our submission fail based on that... and why can't we reproduce the nfVar error... arggh.

@paciorek
Copy link
Contributor Author

I did things more carefully and verified that with UBSAN (i.e., no -fsanitize=address) then R CMD check with R-devel and clang-3.9 does not give any memory leak issues, so that suggests that is what CRAN is running.

That said, I can't get the nfVar error to show up. I've just been running the nfVar example directly. I wonder if somehow running all the examples together would do it, but I presume that happens in R CMD check, and we're not seeing an error report from there.

@perrydv
Copy link
Contributor

perrydv commented Sep 16, 2016

Could it have to do with the environment in which the examples are actually run during building of the Rd pages?

On Sep 16, 2016, at 3:18 PM, Christopher Paciorek [email protected] wrote:

I did things more carefully and verified that with UBSAN (i.e., no -fsanitize=address) then R CMD check with R-devel and clang-3.9 does not give any memory leak issues, so that suggests that is what CRAN is running.

That said, I can't get the nfVar error to show up. I've just been running the nfVar example directly. I wonder if somehow running all the examples together would do it, but I presume that happens in R CMD check, and we're not seeing an error report from there.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub #229 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/AHpCMdCHhIAnMgBB8o7tinNxr0y13JvCks5qqxWigaJpZM4J6-Ip.

@paciorek
Copy link
Contributor Author

my running of R CMD check creates nimble.Rcheck/nimble-Ex.Rout that has the same format as we see in the clang-UBSAN file posted by CRAN, so that suggests it is being created as part of R CMD check.

@perrydv
Copy link
Contributor

perrydv commented Sep 18, 2016

branch compilation_overlaps3 is now ready to be tested. specifically @paciorek please check it with your UBSAN setup.

all other testing of people's code is also welcome on this branch. the changes represent an overdue cleanup and reorganization of which compilation unit has which built-in interface function and how the .Call()s in the R code look up the compiled functions they need. I've run through all our testing, so the remaining risk would be any cases not represented in the test suite.

A new module for the test suite could systematically check every feature of compilation and ensuing build-in interface calls, but that will be a separate issue. By every feature of compilation, I don't mean every keyword but rather every use of every interface functions via the situations in which they are needed.

@paciorek
Copy link
Contributor Author

I'm seeing the following when running R CMD check using ASAN+UBSAN.

Note that all the address/memory stuff showing up when checking examples is coming from teh ASAN checking.

www.stat.berkeley.edu/~paciorek/transfer/00check.log

Also the following was printed after the output of R CMD check:

==4029==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1368 byte(s) in 3 object(s) allocated from:
    #0 0x4c923c  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0x4c923c)
    #1 0x7f230d1bcc44  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/modules//internet.so+0x72c44)
    #2 0xcb76c6  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xcb76c6)
    #3 0x7b23db  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0x7b23db)
    #4 0xaf468c  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf468c)
    #5 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #6 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #7 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #8 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #9 0xb80f49  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb80f49)
    #10 0xbd3596  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xbd3596)
    #11 0xbd3ad4  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xbd3ad4)
    #12 0xada54f  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xada54f)
    #13 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #14 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #15 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #16 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #17 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #18 0xb8dc90  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb8dc90)
    #19 0x5464e3  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0x5464e3)
    #20 0xd946ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xd946ab)
    #21 0xaf5b61  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf5b61)
    #22 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #23 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #24 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #25 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #26 0xb80f49  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb80f49)
    #27 0xbd3596  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xbd3596)
    #28 0xbd3ad4  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xbd3ad4)
    #29 0xada54f  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xada54f)

Direct leak of 912 byte(s) in 2 object(s) allocated from:
    #0 0x4c923c  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0x4c923c)
    #1 0x7f230d1b0684  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/modules//internet.so+0x66684)
    #2 0xcb4873  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xcb4873)
    #3 0x7b247a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0x7b247a)
    #4 0xaf468c  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf468c)
    #5 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #6 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #7 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #8 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #9 0xb80f49  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb80f49)
    #10 0xbd3596  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xbd3596)
    #11 0xbd3ad4  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xbd3ad4)
    #12 0xada54f  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xada54f)
    #13 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #14 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #15 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #16 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #17 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #18 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #19 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #20 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #21 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #22 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #23 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #24 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #25 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #26 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #27 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #28 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #29 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)

Direct leak of 456 byte(s) in 1 object(s) allocated from:
    #0 0x4c923c  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0x4c923c)
    #1 0x7f230d1b0684  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/modules//internet.so+0x66684)
    #2 0xcb4873  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xcb4873)
    #3 0x7b247a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0x7b247a)
    #4 0xaf468c  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf468c)
    #5 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #6 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #7 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #8 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #9 0xb80f49  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb80f49)
    #10 0xbd3596  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xbd3596)
    #11 0xbd3ad4  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xbd3ad4)
    #12 0xada54f  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xada54f)
    #13 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #14 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #15 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #16 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #17 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #18 0xb8dc90  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb8dc90)
    #19 0x5464e3  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0x5464e3)
    #20 0xd946ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xd946ab)
    #21 0xaf5b61  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf5b61)
    #22 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #23 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #24 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #25 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #26 0xb80f49  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb80f49)
    #27 0xbd3596  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xbd3596)
    #28 0xbd3ad4  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xbd3ad4)
    #29 0xada54f  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xada54f)

Direct leak of 456 byte(s) in 1 object(s) allocated from:
    #0 0x4c923c  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0x4c923c)
    #1 0x7f230d1b0684  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/modules//internet.so+0x66684)
    #2 0xcb4873  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xcb4873)
    #3 0x7b247a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0x7b247a)
    #4 0xaf468c  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf468c)
    #5 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #6 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #7 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #8 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #9 0xb80f49  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb80f49)
    #10 0xbd3596  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xbd3596)
    #11 0xbd3ad4  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xbd3ad4)
    #12 0xada54f  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xada54f)
    #13 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #14 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #15 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #16 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #17 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #18 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #19 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #20 0xb80f49  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb80f49)
    #21 0xbd3596  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xbd3596)
    #22 0xbd3ad4  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xbd3ad4)
    #23 0xada54f  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xada54f)
    #24 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #25 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #26 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)
    #27 0xac352a  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xac352a)
    #28 0xb884ab  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xb884ab)
    #29 0xaf2551  (/usr/local/R-devel_2016-09-12-clang39-san/lib64/R/bin/exec/R+0xaf2551)

SUMMARY: AddressSanitizer: 3192 byte(s) leaked in 7 allocation(s).

@perrydv
Copy link
Contributor

perrydv commented Sep 19, 2016

I can't do anything with this output unless you can isolate the example or call each one comes from as specifically as possible.

@perrydv
Copy link
Contributor

perrydv commented Sep 19, 2016

Ok, now I see the output at the link you gave. That is a little more useful. Let's talk tomorrow.

@perrydv
Copy link
Contributor

perrydv commented Sep 26, 2016

Ok, I think this long saga is nearly dealt with.

On branch compilation_overlaps4:

  • Better separation of what goes into nimble.so and libnimble.a or libnimble.dylib (or other extenstion)
  • Better propagation of Dlls throughout the R code
  • The separation above leads back into problems with unloading a DLL and then having crashes upon exit or other garbage collection by R since finalizers have been unloaded. This necessitates further changes:
  • Adaptation of a design sketched by DTL for inserting a layer into handling of finalizers. Now finalizer registration is driven from R, and a generic finalizer is called that actually manages a C++ map of [extptr, real finalizer function pointer] pairs, also with DLL information kept track of. That means we can manually finalize, or R can finalize, and if managed properly we should never call an unloaded finalizer, and with further changes below we should never have unloaded a DLL without finalizing all of its C++ objects first.
  • Generation of a session-specific DLL at time of first compileNimble use that goes all the way to loading a DLL. The session-specific DLL includes the C++ global object keeping track of all finalizers and the functions to use it. This DLL should never by unloaded until exiting R.
  • Added a new function clearCompiled(obj) that will clear compiled content of a nimbleProject. This includes manually finalizing C++ objects, setting any external pointers to them to NULL, and sometimes just ensuring that any attempted uses of any remaining interface objects in R will fail safely.
  • R CMD CHECK --as-cran assumes limited uses of .Call. Specifically it assumes it can determine safe usages by looking at the first argument (and sometimes the PACKAGE argument) during package checking. This does not accommodate nimble's on-the-fly compilation of DLLs, so I had to work around it.
  • As of now the UBSAN seems to pass, specifically the case of compileNimble that was in an Rd example (happened to be for nfVar, but I don't think that's the pertinent point).
  • There are a couple of issues like something about the roxygen for runMCMC and a few other tweaks I'd like to discuss separately before going back to CRAN, but I think we are over the big hurdle (why did we have to fix it if it wasn't broken?) of this Issue.

@danielturek
Copy link
Member

What's the issue with the roxygen for runMCMC ?

@perrydv
Copy link
Contributor

perrydv commented Oct 5, 2016

I'm closing this now, as we think the issue is dealt with. It's difficult to tell since we couldn't reproduce it.

(@danielturek, I think the runMCMC roxygen issue may have been that Rd was out of date with roxygen and something wasn't happy, but it seems to resolve itself when Chris rebuilt the Rd files)

@perrydv perrydv closed this as completed Oct 5, 2016
@danielturek
Copy link
Member

Good to know. If that was at some point assigned to me, then I had lost track of it anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants