[R-pkg-devel] Compiled code checks raise a WARNING in Fedora 28

2018-05-23 Thread Iñaki Úcar
Hi,

For other Fedora users that may be struggling with this too...

Fedora 28 introduced new hardening flags for compiled code (see [1]).
Particularly, -D_GLIBCXX_ASSERTIONS is added to the default CXXFLAGS
(verify the output of 'R CMD config CXXFLAGS'), which enables range
checks for C++ arrays, vectors and strings. As a consequence, you may
see the following after running 'R CMD check' on your package with C++
code:

checking compiled code ... WARNING
Found ‘abort’, possibly from ‘abort’ (C)
Found ‘printf’, possibly from ‘printf’ (C)

I'm not sure whether this is a false positive or not. Anyway, a quick
workaround is to disable this flag by including -U_GLIBCXX_ASSERTIONS
in your local Makevars.

Regards,
Iñaki

[1] https://fedoraproject.org/wiki/Changes/HardeningFlags28

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Compiled code checks raise a WARNING in Fedora 28

2018-05-23 Thread Dirk Eddelbuettel

On 23 May 2018 at 17:22, Iñaki Úcar wrote:
| Hi,
| 
| For other Fedora users that may be struggling with this too...
| 
| Fedora 28 introduced new hardening flags for compiled code (see [1]).
| Particularly, -D_GLIBCXX_ASSERTIONS is added to the default CXXFLAGS
| (verify the output of 'R CMD config CXXFLAGS'), which enables range
| checks for C++ arrays, vectors and strings. As a consequence, you may
| see the following after running 'R CMD check' on your package with C++
| code:
| 
| checking compiled code ... WARNING
| Found ‘abort’, possibly from ‘abort’ (C)
| Found ‘printf’, possibly from ‘printf’ (C)
| 
| I'm not sure whether this is a false positive or not. Anyway, a quick
| workaround is to disable this flag by including -U_GLIBCXX_ASSERTIONS
| in your local Makevars.

AFAICT that has little do with Fedora, it is just R being picky. Writing R
Extensions told you about abort() et al for years:

  Under no circumstances should your compiled code ever call @code{abort}
  or @code{exit}@footnote{or where supported the variants @code{_Exit} and
  @code{_exit}.}: these terminate the user's @R{} process, quite possibly
  including all his unsaved work.  One usage that could call @code{abort}
  is the @code{assert} macro in C or C++ functions, which should never be
  active in production code.  The normal way to ensure that is to define
  the macro @code{NDEBUG}, and @command{R CMD INSTALL} does so as part of
  the compilation flags.  If you wish to use @code{assert} during
  development. you can include @code{-UNDEBUG} in @code{PKG_CPPFLAGS}.
  Note that your own @file{src/Makefile} or makefiles in sub-directories
  may also need to define @code{NDEBUG}.

(Quoted from R-release's manual source)

Also:

edd@rob:~/deb/r-base$ ag "Found " src/library/tools/R/sotools.R
481: c(strwrap(gettextf("Found %s, possibly from %s",
702:  strwrap(paste("Found non-API calls to R:",
705:  } else paste("  Found non-API call to R:", sQuote(x))
716:  strwrap(paste("Found no calls to:",
719:  } else paste("  Found no call to:", sQuote(x))
edd@rob:~/deb/r-base$

I am kinda surprised you had not seen these before :)

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Compiled code checks raise a WARNING in Fedora 28

2018-05-23 Thread Iñaki Úcar
2018-05-23 17:40 GMT+02:00 Dirk Eddelbuettel :
>
> On 23 May 2018 at 17:22, Iñaki Úcar wrote:
> | Hi,
> |
> | For other Fedora users that may be struggling with this too...
> |
> | Fedora 28 introduced new hardening flags for compiled code (see [1]).
> | Particularly, -D_GLIBCXX_ASSERTIONS is added to the default CXXFLAGS
> | (verify the output of 'R CMD config CXXFLAGS'), which enables range
> | checks for C++ arrays, vectors and strings. As a consequence, you may
> | see the following after running 'R CMD check' on your package with C++
> | code:
> |
> | checking compiled code ... WARNING
> | Found ‘abort’, possibly from ‘abort’ (C)
> | Found ‘printf’, possibly from ‘printf’ (C)
> |
> | I'm not sure whether this is a false positive or not. Anyway, a quick
> | workaround is to disable this flag by including -U_GLIBCXX_ASSERTIONS
> | in your local Makevars.
>
> AFAICT that has little do with Fedora, it is just R being picky. Writing R
> Extensions told you about abort() et al for years:
>
>   Under no circumstances should your compiled code ever call @code{abort}
>   or @code{exit}@footnote{or where supported the variants @code{_Exit} and
>   @code{_exit}.}: these terminate the user's @R{} process, quite possibly
>   including all his unsaved work.  One usage that could call @code{abort}
>   is the @code{assert} macro in C or C++ functions, which should never be
>   active in production code.  The normal way to ensure that is to define
>   the macro @code{NDEBUG}, and @command{R CMD INSTALL} does so as part of
>   the compilation flags.  If you wish to use @code{assert} during
>   development. you can include @code{-UNDEBUG} in @code{PKG_CPPFLAGS}.
>   Note that your own @file{src/Makefile} or makefiles in sub-directories
>   may also need to define @code{NDEBUG}.
>
> (Quoted from R-release's manual source)

Yes, I know. The thing is that, with -D_GLIBCXX_ASSERTIONS, I see

$ strings src/*.o | grep abort | sort | uniq
abort
__builtin_abort
__cxa_guard_abort

and without it, the first two lines go away. So it seems that those
assertions may result in a call to 'abort'. I don't know whether R is
right or not in its *pickiness* for this particular case.

Iñaki

>
> Also:
>
> edd@rob:~/deb/r-base$ ag "Found " src/library/tools/R/sotools.R
> 481: c(strwrap(gettextf("Found %s, possibly from %s",
> 702:  strwrap(paste("Found non-API calls to R:",
> 705:  } else paste("  Found non-API call to R:", sQuote(x))
> 716:  strwrap(paste("Found no calls to:",
> 719:  } else paste("  Found no call to:", sQuote(x))
> edd@rob:~/deb/r-base$
>
> I am kinda surprised you had not seen these before :)
>
> Dirk
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Compiled code checks raise a WARNING in Fedora 28

2018-05-23 Thread Dirk Eddelbuettel

On 23 May 2018 at 18:09, Iñaki Úcar wrote:
| 2018-05-23 17:40 GMT+02:00 Dirk Eddelbuettel :
| >
| > On 23 May 2018 at 17:22, Iñaki Úcar wrote:
| > | Hi,
| > |
| > | For other Fedora users that may be struggling with this too...
| > |
| > | Fedora 28 introduced new hardening flags for compiled code (see [1]).
| > | Particularly, -D_GLIBCXX_ASSERTIONS is added to the default CXXFLAGS
| > | (verify the output of 'R CMD config CXXFLAGS'), which enables range
| > | checks for C++ arrays, vectors and strings. As a consequence, you may
| > | see the following after running 'R CMD check' on your package with C++
| > | code:
| > |
| > | checking compiled code ... WARNING
| > | Found ‘abort’, possibly from ‘abort’ (C)
| > | Found ‘printf’, possibly from ‘printf’ (C)
| > |
| > | I'm not sure whether this is a false positive or not. Anyway, a quick
| > | workaround is to disable this flag by including -U_GLIBCXX_ASSERTIONS
| > | in your local Makevars.
| >
| > AFAICT that has little do with Fedora, it is just R being picky. Writing R
| > Extensions told you about abort() et al for years:
| >
| >   Under no circumstances should your compiled code ever call @code{abort}
| >   or @code{exit}@footnote{or where supported the variants @code{_Exit} and
| >   @code{_exit}.}: these terminate the user's @R{} process, quite possibly
| >   including all his unsaved work.  One usage that could call @code{abort}
| >   is the @code{assert} macro in C or C++ functions, which should never be
| >   active in production code.  The normal way to ensure that is to define
| >   the macro @code{NDEBUG}, and @command{R CMD INSTALL} does so as part of
| >   the compilation flags.  If you wish to use @code{assert} during
| >   development. you can include @code{-UNDEBUG} in @code{PKG_CPPFLAGS}.
| >   Note that your own @file{src/Makefile} or makefiles in sub-directories
| >   may also need to define @code{NDEBUG}.
| >
| > (Quoted from R-release's manual source)
| 
| Yes, I know. The thing is that, with -D_GLIBCXX_ASSERTIONS, I see
| 
| $ strings src/*.o | grep abort | sort | uniq
| abort
| __builtin_abort
| __cxa_guard_abort
| 
| and without it, the first two lines go away. So it seems that those
| assertions may result in a call to 'abort'. I don't know whether R is
| right or not in its *pickiness* for this particular case.

Doh. I was dense. You are quite right, it seems -- the new instrumentation
'unmasks' more uses of abort which R's shared library symbol grep analysis
stumbles over.  I should have stayed under my rock it seems -- sorry about
the noise.

Dirk
 
| Iñaki
| 
| >
| > Also:
| >
| > edd@rob:~/deb/r-base$ ag "Found " src/library/tools/R/sotools.R
| > 481: c(strwrap(gettextf("Found %s, possibly from %s",
| > 702:  strwrap(paste("Found non-API calls to R:",
| > 705:  } else paste("  Found non-API call to R:", sQuote(x))
| > 716:  strwrap(paste("Found no calls to:",
| > 719:  } else paste("  Found no call to:", sQuote(x))
| > edd@rob:~/deb/r-base$
| >
| > I am kinda surprised you had not seen these before :)
| >
| > Dirk
| >
| > --
| > http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] plot graph (png, svg, eps, pdf, vdx, ok tikz) to device

2018-05-23 Thread Rainer Krug
Yes - I a now using grImport and eps (after trying svg and grImport2). I still 
need a temporary file, but I can live with that for the moment.

Thanks,

Rainer


> On 15 May 2018, at 14:00, Rainer M. Krug  wrote:
> 
> 
> 
> Von meinem iPhone gesendet
> 
>> Am 15.05.2018 um 13:54 schrieb Johannes Ranke > >:
>> 
>> Hi,
>> 
>> have a look at the grImport package. It can import eps, so at least you get a
>> vector based graph.
> 
> Sounds interesting- I’ll check it out tomorrow and report back if it works 
> well.
> 
>> 
>> Alternatively, you may want to check grImport2 which imports svg.
>> 
>> Kind regards,
>> 
>> Johannes
>> 
>> Am Dienstag, 15. Mai 2018, 13:22:16 CEST schrieb Rainer Krug:
>>> Hi
>>> 
>>> I asked the question at stack exchange yesterday (
>>> https://stackoverflow.com/q/50325139/632423 ) and did not get a response so
>>> far, so I repost it here:
>>> 
>>> 
>>> 
>>> I have the following situation: I use an external command (plantuml -
>>> http://plantuml.com/ ) to create a graph. This is done via R by using a
>>> (my) package ( https://github.com/rkrug/plantuml ). The resulting graph can
>>> be a file (png, svg, eps, pdf, vdx or LaTeX/Tikz with or without preamble)
>>> or I can send the image to stdout, using the same formats.
>>> 
>>> Now I want to plot this graph as R-like as possible, i.e. in a graphic
>>> device. At the moment I am using a temporary file, which I display using
>>> readPNG() and grid::grid.raster() which works, but I am not that happy with
>>> this approach as
>>> 
>>>   • I have to use a temporary file which I would like to avoid, and
>>>   • it is a raster format and I would prefer a vector format.
>>> 
>>> My question is therefore:
>>> 
>>>   • Is there a way to display any of the vector formats in a graphics device
>>> in R? • Can I pipe stdout (the result from the call to plantuml) directly
>>> into the device (or through any function) without having to create an
>>> intermediate file?
>>> 
>>> 
>>> 
>>> Thanks for any [pointers,
>>> 
>>> Rainer
>>> 
>>> 
>>> --
>>> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
>>> UCT), Dipl. Phys. (Germany)
>>> 
>>> University of Zürich
>>> 
>>> Cell:   +41 (0)78 630 66 57
>>> email:  rai...@krugs.de
>>> Skype:  RMkrug
>>> 
>>> PGP: 0x0F52F982
>> 
>> 
>> --
>> Johannes Ranke
>> Wissenschaftlicher Berater
>> https://jrwb.de/contact
> 
> __
> R-package-devel@r-project.org  mailing 
> list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel 
> 
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, 
UCT), Dipl. Phys. (Germany)

University of Zürich

Cell:   +41 (0)78 630 66 57
email:  rai...@krugs.de
Skype:  RMkrug

PGP: 0x0F52F982





signature.asc
Description: Message signed with OpenPGP
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel