Re: [R-SIG-Mac] Advise on building R on OSX without optimization for debugging

2020-07-13 Thread Prof Brian Ripley

On 13/07/2020 11:14, Simon Urbanek wrote:




On Jul 13, 2020, at 7:59 PM, Prof Brian Ripley  wrote:

On 08/07/2020 21:38, Simon Urbanek wrote:

Dmitriy,
due to permissions and the various limitations on passing environment variables 
across processes it is often easier to simply run R and attach the debugger to 
it:
$ R
[...]

Sys.getpid()

[1] 89955



$ sudo lldb
Password:
(lldb) attach 89955
[...]
(lldb) c
Process 89955 resuming


On Catalina I can do that for a version of R I compiled, but not for a 
notarized binary distribution (which also refuses to be run under a debugger).  
The lldb error message is maximally uninformative:

(lldb) attach 16682
error: attach failed: Error 1

or

(lldb) run
error: process exited with status -1 (Error 1)

I presume that is intentional on Apple's part and there is no way round it 
other than weakening security (e.g. disable SIP)?




Correct. It is annoying enough that it made to to the FAQ:

https://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#I-cannot-attach-debugger-to-R

So the recommended way is to use the non-notarised builds (you can also disable 
SIP but that is not recommended). And, yes, it would be nice if lldb provided a 
more useful error...

I suspect that it would be actually sufficient to provide just a exec/R binary 
that doesn't use hardened run-time, but it couldn't be distributed in the Apple 
Installer ... unless we create it with the post install script ... something to 
test I suppose...


Thanks.  My issues have been when my own build works but yours does not 
but while I am still checking on High Sierra I have workarounds.  AFAIR 
the issues have all been array overruns which only sometimes cause 
segfaults.



Best,
Simon





My memory was that it did work on High Sierra (I sometimes use it to 
investigate packages which segfault under your distribution but not with my 
builds) and I have just re-checked there with the CRAN distribution of 4.0.2.

Brian Ripley

--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford

___
R-SIG-Mac mailing list
R-SIG-Mac@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mac





--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford

___
R-SIG-Mac mailing list
R-SIG-Mac@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mac


Re: [R-SIG-Mac] Advise on building R on OSX without optimization for debugging

2020-07-13 Thread Simon Urbanek



> On Jul 13, 2020, at 7:59 PM, Prof Brian Ripley  wrote:
> 
> On 08/07/2020 21:38, Simon Urbanek wrote:
>> Dmitriy,
>> due to permissions and the various limitations on passing environment 
>> variables across processes it is often easier to simply run R and attach the 
>> debugger to it:
>> $ R
>> [...]
>>> Sys.getpid()
>> [1] 89955
>>> 
>> $ sudo lldb
>> Password:
>> (lldb) attach 89955
>> [...]
>> (lldb) c
>> Process 89955 resuming
> 
> On Catalina I can do that for a version of R I compiled, but not for a 
> notarized binary distribution (which also refuses to be run under a 
> debugger).  The lldb error message is maximally uninformative:
> 
> (lldb) attach 16682
> error: attach failed: Error 1
> 
> or
> 
> (lldb) run
> error: process exited with status -1 (Error 1)
> 
> I presume that is intentional on Apple's part and there is no way round it 
> other than weakening security (e.g. disable SIP)?
> 


Correct. It is annoying enough that it made to to the FAQ:

https://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#I-cannot-attach-debugger-to-R

So the recommended way is to use the non-notarised builds (you can also disable 
SIP but that is not recommended). And, yes, it would be nice if lldb provided a 
more useful error...

I suspect that it would be actually sufficient to provide just a exec/R binary 
that doesn't use hardened run-time, but it couldn't be distributed in the Apple 
Installer ... unless we create it with the post install script ... something to 
test I suppose...

Best,
Simon




> My memory was that it did work on High Sierra (I sometimes use it to 
> investigate packages which segfault under your distribution but not with my 
> builds) and I have just re-checked there with the CRAN distribution of 4.0.2.
> 
> Brian Ripley
> 
> -- 
> Brian D. Ripley,  rip...@stats.ox.ac.uk
> Emeritus Professor of Applied Statistics, University of Oxford
> 
> ___
> R-SIG-Mac mailing list
> R-SIG-Mac@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac

___
R-SIG-Mac mailing list
R-SIG-Mac@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mac


Re: [R-SIG-Mac] Advise on building R on OSX without optimization for debugging

2020-07-13 Thread Prof Brian Ripley

On 08/07/2020 21:38, Simon Urbanek wrote:

Dmitriy,

due to permissions and the various limitations on passing environment variables 
across processes it is often easier to simply run R and attach the debugger to 
it:

$ R
[...]

Sys.getpid()

[1] 89955




$ sudo lldb
Password:
(lldb) attach 89955
[...]
(lldb) c
Process 89955 resuming


On Catalina I can do that for a version of R I compiled, but not for a 
notarized binary distribution (which also refuses to be run under a 
debugger).  The lldb error message is maximally uninformative:


(lldb) attach 16682
error: attach failed: Error 1

or

(lldb) run
error: process exited with status -1 (Error 1)

I presume that is intentional on Apple's part and there is no way round 
it other than weakening security (e.g. disable SIP)?


My memory was that it did work on High Sierra (I sometimes use it to 
investigate packages which segfault under your distribution but not with 
my builds) and I have just re-checked there with the CRAN distribution 
of 4.0.2.


Brian Ripley

--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford

___
R-SIG-Mac mailing list
R-SIG-Mac@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mac


Re: [R-SIG-Mac] Advise on building R on OSX without optimization for debugging

2020-07-09 Thread Dmitriy Selivanov
Thanks, Simon,
That helped a lot and I was able to debug the error.
Also I got another advice in a private email from Rodney Sparapani where he
suggested making symlinks to libRblas.dylib, libR.dylib in the workdir.
That worked as well.


On Thu, Jul 9, 2020 at 1:16 AM Simon Urbanek 
wrote:

> Dmitriy,
>
> due to permissions and the various limitations on passing environment
> variables across processes it is often easier to simply run R and attach
> the debugger to it:
>
> $ R
> [...]
> > Sys.getpid()
> [1] 89955
> >
>
> $ sudo lldb
> Password:
> (lldb) attach 89955
> [...]
> (lldb) c
> Process 89955 resuming
>
> Also note that you shouldn't change Makeconf by hand, simply supply any
> CFLAGS you need to configure, e.g.:
>
> ../R-devel/configure --enable-R-shlib 'CFLAGS=-Wall -g -O0'
> 'CXXFLAGS=-Wall -g -O0'
>
> Cheers,
> Simon
>
>
> > On Jul 8, 2020, at 11:08 PM, Dmitriy Selivanov <
> selivanov.dmit...@gmail.com> wrote:
> >
> > Dear all,
> >
> > I'm trying to debug a segfault reported here
> > https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17850 (thanks Kevin
> for
> > the nice article
> > https://kevinushey.github.io/blog/2015/04/13/debugging-with-lldb/ about
> > debugging with lldb)
> >
> > I need to compile R without optimization (with the O0 flag) instead of
> > using binaries provided by Simon.
> >
> > Here I have difficulties. What I've tried:
> >
> >   1. Downloaded latest R-devel from
> >   https://stat.ethz.ch/R/daily/R-devel.tar.gz
> >   2. Downloaded xz and pcre2 as suggested here
> >   https://mac.r-project.org/tools/
> >   3. run ./confilgure
> >   4. replaced O2 with O0 in Makeconf
> >   5. make
> >
> > Now R is compiled and I can launch it with ./bin/R. However when I run it
> > with lldb
> >
> >   1. ./bin/R -d lldb
> >   2. run
> >
> > I'm, getting:
> >
> > Process 74482 launched:
> > '/Users/dmitry.selivanov/Downloads/R-devel/bin/exec/R' (x86_64)
> >
> > dyld: Library not loaded: libRblas.dylib
> >
> >  Referenced from: /Users/dmitry.selivanov/Downloads/R-devel/bin/exec/R
> >
> >  Reason: image not found
> >
> > Process 74482 stopped
> >
> > * thread #1, stop reason = signal SIGABRT
> >
> >frame #0: 0x000100574ebe dyld`__abort_with_payload + 10
> >
> > dyld`__abort_with_payload:
> >
> > ->  0x100574ebe <+10>: jae0x100574ec8   ; <+20>
> >
> >0x100574ec0 <+12>: movq   %rax, %rdi
> >
> >0x100574ec3 <+15>: jmp0x1005733e8   ; cerror_nocancel
> >
> >0x100574ec8 <+20>: retq
> >
> > Target 0: (R) stopped.
> >
> >
> > Any suggestions? Things are much easier on linux-based docker images,
> but I
> > can't reproduce the reported bug there...
> >
> >
> > Regards
> > Dmitriy Selivanov
> >
> >   [[alternative HTML version deleted]]
> >
> > ___
> > R-SIG-Mac mailing list
> > R-SIG-Mac@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> >
>
>

-- 
Regards
Dmitriy Selivanov

[[alternative HTML version deleted]]

___
R-SIG-Mac mailing list
R-SIG-Mac@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mac


Re: [R-SIG-Mac] Advise on building R on OSX without optimization for debugging

2020-07-08 Thread Simon Urbanek
Dmitriy,

due to permissions and the various limitations on passing environment variables 
across processes it is often easier to simply run R and attach the debugger to 
it:

$ R
[...]
> Sys.getpid()
[1] 89955
> 

$ sudo lldb
Password:
(lldb) attach 89955
[...]
(lldb) c
Process 89955 resuming

Also note that you shouldn't change Makeconf by hand, simply supply any CFLAGS 
you need to configure, e.g.:

../R-devel/configure --enable-R-shlib 'CFLAGS=-Wall -g -O0' 'CXXFLAGS=-Wall -g 
-O0'

Cheers,
Simon


> On Jul 8, 2020, at 11:08 PM, Dmitriy Selivanov  
> wrote:
> 
> Dear all,
> 
> I'm trying to debug a segfault reported here
> https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17850 (thanks Kevin for
> the nice article
> https://kevinushey.github.io/blog/2015/04/13/debugging-with-lldb/ about
> debugging with lldb)
> 
> I need to compile R without optimization (with the O0 flag) instead of
> using binaries provided by Simon.
> 
> Here I have difficulties. What I've tried:
> 
>   1. Downloaded latest R-devel from
>   https://stat.ethz.ch/R/daily/R-devel.tar.gz
>   2. Downloaded xz and pcre2 as suggested here
>   https://mac.r-project.org/tools/
>   3. run ./confilgure
>   4. replaced O2 with O0 in Makeconf
>   5. make
> 
> Now R is compiled and I can launch it with ./bin/R. However when I run it
> with lldb
> 
>   1. ./bin/R -d lldb
>   2. run
> 
> I'm, getting:
> 
> Process 74482 launched:
> '/Users/dmitry.selivanov/Downloads/R-devel/bin/exec/R' (x86_64)
> 
> dyld: Library not loaded: libRblas.dylib
> 
>  Referenced from: /Users/dmitry.selivanov/Downloads/R-devel/bin/exec/R
> 
>  Reason: image not found
> 
> Process 74482 stopped
> 
> * thread #1, stop reason = signal SIGABRT
> 
>frame #0: 0x000100574ebe dyld`__abort_with_payload + 10
> 
> dyld`__abort_with_payload:
> 
> ->  0x100574ebe <+10>: jae0x100574ec8   ; <+20>
> 
>0x100574ec0 <+12>: movq   %rax, %rdi
> 
>0x100574ec3 <+15>: jmp0x1005733e8   ; cerror_nocancel
> 
>0x100574ec8 <+20>: retq
> 
> Target 0: (R) stopped.
> 
> 
> Any suggestions? Things are much easier on linux-based docker images, but I
> can't reproduce the reported bug there...
> 
> 
> Regards
> Dmitriy Selivanov
> 
>   [[alternative HTML version deleted]]
> 
> ___
> R-SIG-Mac mailing list
> R-SIG-Mac@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> 

___
R-SIG-Mac mailing list
R-SIG-Mac@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mac


[R-SIG-Mac] Advise on building R on OSX without optimization for debugging

2020-07-08 Thread Dmitriy Selivanov
Dear all,

I'm trying to debug a segfault reported here
https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17850 (thanks Kevin for
the nice article
https://kevinushey.github.io/blog/2015/04/13/debugging-with-lldb/ about
debugging with lldb)

I need to compile R without optimization (with the O0 flag) instead of
using binaries provided by Simon.

Here I have difficulties. What I've tried:

   1. Downloaded latest R-devel from
   https://stat.ethz.ch/R/daily/R-devel.tar.gz
   2. Downloaded xz and pcre2 as suggested here
   https://mac.r-project.org/tools/
   3. run ./confilgure
   4. replaced O2 with O0 in Makeconf
   5. make

Now R is compiled and I can launch it with ./bin/R. However when I run it
with lldb

   1. ./bin/R -d lldb
   2. run

I'm, getting:

Process 74482 launched:
'/Users/dmitry.selivanov/Downloads/R-devel/bin/exec/R' (x86_64)

dyld: Library not loaded: libRblas.dylib

  Referenced from: /Users/dmitry.selivanov/Downloads/R-devel/bin/exec/R

  Reason: image not found

Process 74482 stopped

* thread #1, stop reason = signal SIGABRT

frame #0: 0x000100574ebe dyld`__abort_with_payload + 10

dyld`__abort_with_payload:

->  0x100574ebe <+10>: jae0x100574ec8   ; <+20>

0x100574ec0 <+12>: movq   %rax, %rdi

0x100574ec3 <+15>: jmp0x1005733e8   ; cerror_nocancel

0x100574ec8 <+20>: retq

Target 0: (R) stopped.


Any suggestions? Things are much easier on linux-based docker images, but I
can't reproduce the reported bug there...


Regards
Dmitriy Selivanov

[[alternative HTML version deleted]]

___
R-SIG-Mac mailing list
R-SIG-Mac@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mac