Re: [R-SIG-Mac] problem with Rprof

2022-11-06 Thread Simon Urbanek
Carl,

first, setting such low interval won't work anyway - the overhead is bigger 
than the sampled time, so we should really not allow it to begin with (on my 
machine the timer signals arrive before anything can be done so you have to 
kill R and you get no output).

That said, it crashes in doprof() which is called on all threads - the main R 
one is ok, but one of the other threads crashes in pthread_self(). At that time 
R is trying to propagate the signal from all threads to the main thread which 
seems odd to me (since the main thread already got the signal), I'm CCing Luke 
in the hope that he has any ideas. This may fall in the category of "don't do 
this" and the fix may be to set a lower bound on the interval.

Cheers,
Simon



> On Nov 6, 2022, at 6:46 AM, Carl Witthoft  wrote:
> 
> Wondering if this is a hiccup in  R-mac 4.2.1 (running under 11.6.8 Big Sur), 
> or a bug in Rprof:
> 
> If I try to set a very small time interval,
> 
> >>  Rprof(interval = 0.01)  ,
> R crashes.
> 
> Crash report follows:
> 
> Process:   R [54439]
> Path:  /Applications/R.app/Contents/MacOS/R
> Identifier:org.R-project.R
> Version:   R 4.2.1 GUI 1.79 High Sierra build (8095)
> Code Type: X86-64 (Native)
> Parent Process:??? [1]
> Responsible:   R [54439]
> User ID:   502
> 
> Date/Time: 2022-11-05 13:37:36.003 -0400
> OS Version:macOS 11.6.8 (20G730)
> Report Version:12
> Anonymous UUID:B755C094-C366-46AB-8EEA-9D3B8E7B388D
> 
> Sleep/Wake UUID:   6135D492-FF9D-4ED1-AF9F-C0F790F64110
> 
> Time Awake Since Boot: 150 seconds
> Time Since Wake:   7200 seconds
> 
> System Integrity Protection: enabled
> 
> Crashed Thread:6
> 
> Exception Type:EXC_BAD_ACCESS (SIGSEGV)
> Exception Codes:   KERN_INVALID_ADDRESS at 0x
> Exception Note:EXC_CORPSE_NOTIFY
> 
> Termination Signal:Segmentation fault: 11
> Termination Reason:Namespace SIGNAL, Code 0xb
> Terminating Process:   exc handler [54439]
> 
> VM Regions Near 0:
> -->
>__TEXT  103034000-1030bc000[  544K] r-x/r-x SM=COW 
>  /Applications/R.app/Contents/MacOS/R
> 
> Thread 0:: Dispatch queue: com.apple.main-thread
> 0   libsystem_kernel.dylib0x7fff208cdf4a __sigaction + 10
> 1   libsystem_platform.dylib  0x7fff2094367c __platform_sigaction 
> + 103
> 2   libsystem_c.dylib 0x7fff207fe689 signal__ + 66
> 3   libR.dylib0x00010323a23c doprof + 1676 
> (eval.c:345)
> 4   libsystem_platform.dylib  0x7fff20943d7d _sigtramp + 29
> 5   ???   0x8000 0 + 
> 9223372036854775808
> 6   libsystem_malloc.dylib0x7fff207255ed nanov2_allocate + 367
> 7   libsystem_malloc.dylib0x7fff2072754d nanov2_calloc + 123
> 8   libsystem_malloc.dylib0x7fff2073fff4 _malloc_zone_calloc 
> + 59
> 9   libobjc.A.dylib   0x7fff2079c5fa class_createInstance 
> + 65
> 10  com.apple.CoreFoundation  0x7fff2097a335 __CFAllocateObject + 
> 15
> 11  com.apple.CoreFoundation  0x7fff20980f04 __NSDictionaryI_new 
> + 126
> 12  com.apple.CoreFoundation  0x7fff20980d48 +[NSDictionary 
> dictionaryWithObjects:forKeys:count:] + 49
> 13  com.apple.AppKit  0x7fff23a5 
> -[_NSToolbarButtonCell _symbolImageHints] + 213
> 14  com.apple.AppKit  0x7fff2326659a -[NSButtonCell 
> _currentImageInView:] + 401
> 15  com.apple.AppKit  0x7fff232c0992 -[NSButtonCell 
> _effectiveContentStyleForImageInView:] + 184
> 16  com.apple.AppKit  0x7fff232646c4 -[NSButtonCell 
> _updateImageViewImageInView:] + 93
> 17  com.apple.AppKit  0x7fff232645a4 __60-[NSButtonCell 
> _updateSubviewsInView:includeTitleTextField:]_block_invoke + 134
> 18  com.apple.AppKit  0x7fff231ea835 +[NSAppearance 
> _performWithCurrentAppearance:usingBlock:] + 66
> 19  com.apple.AppKit  0x7fff23231321 -[NSButtonCell 
> _updateSubviewsInView:includeTitleTextField:] + 131
> 20  com.apple.AppKit  0x7fff232310eb -[NSButton 
> updateCell:] + 87
> 21  com.apple.AppKit  0x7fff23230a84 -[NSCell 
> setEnabled:] + 156
> 22  com.apple.AppKit  0x7fff23230d0f -[NSControl 
> setEnabled:] + 120
> 23  com.apple.AppKit  0x7fff2330af46 -[NSToolbarItem 
> _reallySetEnabled:] + 124
> 24  org.R-project.R   0x00010304542b Re_RBusy + 59
> 25  libR.dylib0x0001032694bf R_ReplDLLdo1 + 559 
> (main.c:408)
> 26  org.R-project.R   0x000103052e15 run_REngineRmainloop 
> + 261
> 27  org.R-project.R   0x00010304798f -[REngine runREPL] + 
> 143
>

[R-SIG-Mac] problem with Rprof

2022-11-05 Thread Carl Witthoft
Wondering if this is a hiccup in  R-mac 4.2.1 (running under 11.6.8 Big 
Sur), or a bug in Rprof:


If I try to set a very small time interval,

>>  Rprof(interval = 0.01)  ,
R crashes.

Crash report follows:

Process:   R [54439]
Path:  /Applications/R.app/Contents/MacOS/R
Identifier:org.R-project.R
Version:   R 4.2.1 GUI 1.79 High Sierra build (8095)
Code Type: X86-64 (Native)
Parent Process:??? [1]
Responsible:   R [54439]
User ID:   502

Date/Time: 2022-11-05 13:37:36.003 -0400
OS Version:macOS 11.6.8 (20G730)
Report Version:12
Anonymous UUID:B755C094-C366-46AB-8EEA-9D3B8E7B388D

Sleep/Wake UUID:   6135D492-FF9D-4ED1-AF9F-C0F790F64110

Time Awake Since Boot: 150 seconds
Time Since Wake:   7200 seconds

System Integrity Protection: enabled

Crashed Thread:6

Exception Type:EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:   KERN_INVALID_ADDRESS at 0x
Exception Note:EXC_CORPSE_NOTIFY

Termination Signal:Segmentation fault: 11
Termination Reason:Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [54439]

VM Regions Near 0:
-->
__TEXT  103034000-1030bc000[  544K] r-x/r-x 
SM=COW  /Applications/R.app/Contents/MacOS/R


Thread 0:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib  0x7fff208cdf4a __sigaction + 10
1   libsystem_platform.dylib  	0x7fff2094367c 
__platform_sigaction + 103

2   libsystem_c.dylib   0x7fff207fe689 signal__ + 66
3   libR.dylib	0x00010323a23c doprof + 1676 
(eval.c:345)

4   libsystem_platform.dylib0x7fff20943d7d _sigtramp + 29
5   ???   	0x8000 0 + 
9223372036854775808

6   libsystem_malloc.dylib  0x7fff207255ed nanov2_allocate + 367
7   libsystem_malloc.dylib  0x7fff2072754d nanov2_calloc + 123
8   libsystem_malloc.dylib	0x7fff2073fff4 
_malloc_zone_calloc + 59
9   libobjc.A.dylib   	0x7fff2079c5fa 
class_createInstance + 65
10  com.apple.CoreFoundation  	0x7fff2097a335 __CFAllocateObject 
+ 15
11  com.apple.CoreFoundation  	0x7fff20980f04 
__NSDictionaryI_new + 126
12  com.apple.CoreFoundation  	0x7fff20980d48 +[NSDictionary 
dictionaryWithObjects:forKeys:count:] + 49
13  com.apple.AppKit  	0x7fff23a5 
-[_NSToolbarButtonCell _symbolImageHints] + 213
14  com.apple.AppKit  	0x7fff2326659a -[NSButtonCell 
_currentImageInView:] + 401
15  com.apple.AppKit  	0x7fff232c0992 -[NSButtonCell 
_effectiveContentStyleForImageInView:] + 184
16  com.apple.AppKit  	0x7fff232646c4 -[NSButtonCell 
_updateImageViewImageInView:] + 93
17  com.apple.AppKit  	0x7fff232645a4 __60-[NSButtonCell 
_updateSubviewsInView:includeTitleTextField:]_block_invoke + 134
18  com.apple.AppKit  	0x7fff231ea835 +[NSAppearance 
_performWithCurrentAppearance:usingBlock:] + 66
19  com.apple.AppKit  	0x7fff23231321 -[NSButtonCell 
_updateSubviewsInView:includeTitleTextField:] + 131
20  com.apple.AppKit  	0x7fff232310eb -[NSButton 
updateCell:] + 87
21  com.apple.AppKit  	0x7fff23230a84 -[NSCell 
setEnabled:] + 156
22  com.apple.AppKit  	0x7fff23230d0f -[NSControl 
setEnabled:] + 120
23  com.apple.AppKit  	0x7fff2330af46 -[NSToolbarItem 
_reallySetEnabled:] + 124

24  org.R-project.R 0x00010304542b Re_RBusy + 59
25  libR.dylib	0x0001032694bf R_ReplDLLdo1 + 559 
(main.c:408)
26  org.R-project.R   	0x000103052e15 
run_REngineRmainloop + 261
27  org.R-project.R   	0x00010304798f -[REngine runREPL] 
+ 143

28  org.R-project.R 0x000103037288 main + 792
29  libdyld.dylib   0x7fff20919f3d start + 1

Thread 1:: JavaScriptCore bmalloc scavenger
0   libsystem_kernel.dylib  0x7fff208cf91e __pthread_kill + 10
1   libsystem_pthread.dylib 0x7fff208fe5bd pthread_kill + 263
2   libR.dylib	0x00010323a24d doprof + 1693 
(eval.c:231)

3   libsystem_platform.dylib0x7fff20943d7d _sigtramp + 29
4   ??? 00 0 + 0
5   libc++.1.dylib	0x7fff20867d72 
std::__1::condition_variable::wait(std::__1::unique_lock&) 
+ 18
6   com.apple.JavaScriptCore  	0x7fff379f0894 void 
std::__1::condition_variable_any::wait 
>(std::__1::unique_lock&) + 84
7   com.apple.JavaScriptCore  	0x7fff379f535b 
bmalloc::Scavenger::threadRunLoop() + 331
8   com.apple.JavaScriptCore  	0x7fff379f4ee9 
bmalloc::Scavenger::threadEntryPoint(bmalloc::Scavenger*) + 9
9   com.apple.Java