Re: [Rd] View() segfaulting ...

2024-04-25 Thread Ivan Krylov via R-devel
On Wed, 24 Apr 2024 19:35:42 -0400
Ben Bolker  wrote:

>  I'm using bleeding-edge R-devel, so maybe my build is weird. Can 
> anyone else reproduce this?
> 
>View() seems to crash on just about anything.

Not for me, sorry.

If you have a sufficiently new processor, you can use `rr` [*] to
capture the crash, set a breakpoint in in_R_X11_dataviewer and rewind,
then set a watchpoint on the stack canary and run the program forward
again:
https://www.redhat.com/en/blog/debugging-stack-protector-failures

If you can't locate the canary, try setting watchpoints on large local
variables. Without `rr`, the procedure is probably the same, but
without rewinding: set a breakpoint in in_R_X11_dataviewer, set some
watchpoints, see if they fire when they shouldn't, start from scratch
if you get past the watchpoints and the process crashes.

I think that that either an object file didn't get rebuilt when it
should have, or a shared library used by something downstream from
View() got an ABI-breaking update. If this still reproduces with a clean
rebuild of R, it's definitely worth investigating further, perhaps using
AddressSanitizer. Valgrind may be lacking the information about the
stack canary and thus failing to distinguish between overwriting the
canary and normal access to a stack variable via a pointer.

-- 
Best regards,
Ivan

[*] https://rr-project.org/
Edit distance of one from the domain name of the R project!

Use rr replay -g $EVENT_NUMBER to debug past the initial execve()
from the shell wrapper: https://github.com/rr-debugger/rr/wiki/FAQ

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


Re: [Rd] View() segfaulting ...

2024-04-24 Thread Ben Bolker
As suggested by Josh Ulrich, here's what I get when running under 
valgrind.



$ R -d valgrind
==218120== Memcheck, a memory error detector
==218120== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==218120== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright 
info

==218120== Command: /usr/local/lib/R/bin/exec/R
==218120==

R Under development (unstable) (2024-04-24 r86483) -- "Unsuffered 
Consequences"

Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

gcoto> gctorture(TRUE)
> View(1:3)
*** stack smashing detected ***: terminated
==218120==
==218120== Process terminating with default action of signal 6 (SIGABRT)
==218120==at 0x4D619FC: __pthread_kill_implementation 
(pthread_kill.c:44)

==218120==by 0x4D619FC: __pthread_kill_internal (pthread_kill.c:78)
==218120==by 0x4D619FC: pthread_kill@@GLIBC_2.34 (pthread_kill.c:89)
==218120==by 0x4D0D475: raise (raise.c:26)
==218120==by 0x4CF37F2: abort (abort.c:79)
==218120==by 0x4D54675: __libc_message (libc_fatal.c:155)
==218120==by 0x4E01599: __fortify_fail (fortify_fail.c:26)
==218120==by 0x4E01565: __stack_chk_fail (stack_chk_fail.c:24)
==218120==by 0x27B686AD: in_R_X11_dataviewer (dataentry.c:540)
==218120==by 0x495C7C7: do_External (dotcode.c:573)
==218120==by 0x499A07F: bcEval_loop (eval.c:8141)
==218120==by 0x49B501C: bcEval (eval.c:7524)
==218120==by 0x49B501C: bcEval (eval.c:7509)
==218120==by 0x49B538A: Rf_eval (eval.c:1167)
==218120==by 0x49B755E: R_execClosure (eval.c:2398)
==218120==
==218120== HEAP SUMMARY:
==218120== in use at exit: 42,061,827 bytes in 9,305 blocks
==218120==   total heap usage: 23,905 allocs, 14,600 frees, 66,039,858 
bytes allocated

==218120==
==218120== LEAK SUMMARY:
==218120==definitely lost: 0 bytes in 0 blocks
==218120==indirectly lost: 0 bytes in 0 blocks
==218120==  possibly lost: 5,868 bytes in 14 blocks
==218120==still reachable: 42,055,959 bytes in 9,291 blocks
==218120==   of which reachable via heuristic:
==218120== newarray   : 4,264 bytes in 1 
blocks

==218120== suppressed: 0 bytes in 0 blocks
==218120== Rerun with --leak-check=full to see details of leaked memory
==218120==
==218120== For lists of detected and suppressed errors, rerun with: -s
==218120== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Aborted (core dumped)
bolker:~/R$

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


[Rd] View() segfaulting ...

2024-04-24 Thread Ben Bolker
  I'm using bleeding-edge R-devel, so maybe my build is weird. Can 
anyone else reproduce this?


  View() seems to crash on just about anything.

View(1:3)
*** stack smashing detected ***: terminated
Aborted (core dumped)

  If I debug(View) I get to the last line of code with nothing 
obviously looking pathological:


Browse[1]>
debug: invisible(.External2(C_dataviewer, x, title))
Browse[1]> x
$x
[1] "1" "2" "3"

Browse[1]> title
[1] "Data: 1:3"
Browse[1]>
*** stack smashing detected ***: terminated
Aborted (core dumped)




R Under development (unstable) (2024-04-24 r86483)
Platform: x86_64-pc-linux-gnu
Running under: Pop!_OS 22.04 LTS

Matrix products: default
BLAS/LAPACK: 
/usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; 
LAPACK version 3.10.0


locale:
 [1] LC_CTYPE=en_CA.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_CA.UTF-8LC_COLLATE=en_CA.UTF-8
 [5] LC_MONETARY=en_CA.UTF-8LC_MESSAGES=en_CA.UTF-8
 [7] LC_PAPER=en_CA.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C

time zone: America/Toronto
tzcode source: system (glibc)

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_4.5.0

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