[Bioc-devel] What to do about std::cerr/cout warnings in external libraries?

Martin Morgan martin.morgan at roswellpark.org
Wed Jun 21 04:12:00 CEST 2017


On 06/20/2017 09:38 PM, Shian Su wrote:
> My warning is
> 
> checking compiled code ... WARNING
> File ‘scPipe/libs/scPipe.so’:
>    Found ‘___stderrp’, possibly from ‘stderr’ (C)
>      Objects: ‘bgzf.o’, ‘hts.o’, ‘sam.o’
>    Found ‘_abort’, possibly from ‘abort’ (C)
>      Object: ‘sam.o’
>    Found ‘_exit’, possibly from ‘exit’ (C)
>      Object: ‘bgzf.o’
> 
> Compiled code should not call entry points which might terminate R nor
> write to stdout/stderr instead of to the console, nor the system RNG.
> 
> As far as I can tell my source files are identical to the ones in Rhtslib, how does Rhtslib avoid this warning? I feel safer with one less dependency but I’ll consider linking to Rhtslib, thanks!

please reuse Rhtslib instead of adding code that requires independent 
maintenance; in particular considerable effort is required to make 
htslib available across platforms. If there are issues with Rhtslib then 
report them and, especially if a patch is provided, they will be fixed.

Rhtslib builds the library in src/htslib/.libs/libhts.so whereas R 
checks src/Rhstlib.so, which contains a single function that reports the 
version. So R doesn't find the use of stderr, etc.

A previous discussion of similar issues is at

   https://stat.ethz.ch/pipermail/bioc-devel/2017-April/010837.html

and other posts in the same thread.

For Rsamtools I had introduced in src/Makevars.common a macro that 
redirects fprintf / exit / abort to code that does not use these macros, 
but to do so requires unsetting _FORTIFY_SOURCE

DFLAGS = -D_USE_KNETFILE -D_FILE_OFFSET_BITS=64 \
   -U_FORTIFY_SOURCE -DBGZF_CACHE \
   -Dfprintf=_samtools_fprintf \
   -Dexit=_samtools_exit \
   -Dabort=_samtools_abort

but this is not a perfect solution.

Martin

> 
> On 20 Jun 2017, at 8:03 pm, Vincent Carey <stvjc at channing.harvard.edu<mailto:stvjc at channing.harvard.edu>> wrote:
> 
> Have you looked at the Bioconductor package Rhtslib?
> 
> Is your package's source visible on github?  If so please provide the URL.
> 
> If not, please provide more details on the error messages observed.
> 
> It would seem to me that the best way to proceed would be to link to Rhtslib.
> 
> On Tue, Jun 20, 2017 at 2:29 AM, Shian Su <su.s at wehi.edu.au<mailto:su.s at wehi.edu.au>> wrote:
> Hi all,
> 
> I am using parts of htslib in a new package. R CMD check gives me warnings about R terminating entry points and such resulting from htslib’s calls. Is there a way to get around this or do I have to go into the source code of htslib and change all their calls.
> 
> Also, Hadley’s best practices recommends using “error” instead of “exit” however I am using Rcpp to glue things together which only seems to provide “stop” for this purpose. Can exits be simply swapped out with Rcpp::stop?
> 
> Kind regards,
> Shian Su
> _______________________________________________
> Bioc-devel at r-project.org<mailto:Bioc-devel at r-project.org> mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> Bioc-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel
> 


This email message may contain legally privileged and/or...{{dropped:2}}



More information about the Bioc-devel mailing list