Re: [Rd] RGtk2 on linux: "stack smashing detected"

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed, 06 Aug 2008 14:44:29 +0100 (BST)

Note that this is happening in R_GetTraceback. Running under gdb told me where (deparse2buff, but I guessed that) and on my system that the problem was in sprintf.

Eh voila:

     case EXTPTRSXP:
     {
 	char tpb[12+sizeof(void *)];
 	d->sourceable = FALSE;
 	sprintf(tpb, "<pointer: %p>", R_ExternalPtrAddr(s));
 	print2buff(tpb, d);
     }
 	break;

is too small a buffer. I've just fixed that in the R sources.

So the unusual circumstance was deparsing an external pointer.

On Wed, 6 Aug 2008, Michael Lawrence wrote:

> Yea I am aware of this. This is because the Ubuntu binary has stack smashing
> detection enabled. It's possible to build R without this checking:
>
> export CFLAGS="-fno-stack-protector"
>
> I have not been able to figure out why stack smashing is detected. I'm
> cc'ing this to r-devel in case anyone else has an idea.
>
> Michael
>
> On Wed, Aug 6, 2008 at 12:31 AM, Felix Andrews <felix_at_nfrac.org> wrote:
>
>> Hi Michael,
>>
>> I wonder whether you have come across this before? I am testing RGtk2
>> on Ubuntu and it seems that any error that occurs in that context
>> kills the R process with a message "stack smashing detected". This is
>> on Ubuntu 8.04. Minimal example:
>>
>>> library(RGtk2)
>>> sessionInfo()
>> R version 2.7.1 (2008-06-23)
>> i486-pc-linux-gnu
>>
>> locale:
>>
>> LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;LC_COLLATE=en_AU.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_AU.UTF-8;LC_PAPER=en_AU.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_AU.UTF-8;LC_IDENTIFICATION=C
>>
>> attached base packages:
>> [1] stats graphics grDevices utils datasets methods base
>>
>> other attached packages:
>> [1] RGtk2_2.12.1
>>> stop("hello")
>> Error: hello
>>> foo <- GtkWindow()
>> Error: could not find function "GtkWindow"
>>> foo <- gtkWindow()
>>> butt <- gtkButton("error")
>>> gSignalConnect(butt, "clicked", function(...) stop("hello"))
>> clicked
>> 16
>> attr(,"class")
>> [1] "CallbackID"
>>> foo$add(butt)
>> ## click button
>>> Error in function (...) : hello
>> *** stack smashing detected ***: /usr/lib/R/bin/exec/R terminated
>> ======= Backtrace: =========
>> /lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x48)[0xb7b98138]
>> /lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x0)[0xb7b980f0]
>> /usr/lib/R/lib/libR.so[0xb7e12094]
>> /usr/lib/R/lib/libR.so[0xb7c8422e]
>> /usr/lib/R/lib/libR.so[0xb7c86fd7]
>> /usr/lib/R/lib/libR.so[0xb7c84082]
>> /usr/lib/R/lib/libR.so[0xb7c87b13]
>> /usr/lib/R/lib/libR.so(R_GetTraceback+0xc6)[0xb7cb8576]
>> /usr/lib/R/lib/libR.so[0xb7cba85c]
>> /usr/lib/R/lib/libR.so[0xb7cb966f]
>> /usr/lib/R/lib/libR.so(Rf_errorcall+0x3af)[0xb7cb9e7f]
>> /usr/lib/R/lib/libR.so[0xb7cba0c5]
>> /usr/lib/R/lib/libR.so[0xb7cfc89a]
>> /usr/lib/R/lib/libR.so(Rf_eval+0x451)[0xb7cc62e1]
>> /usr/lib/R/lib/libR.so[0xb7cc86c2]
>> /usr/lib/R/lib/libR.so(Rf_eval+0x451)[0xb7cc62e1]
>> /usr/lib/R/lib/libR.so[0xb7cc78f0]
>> /usr/lib/R/lib/libR.so(Rf_eval+0x451)[0xb7cc62e1]
>> /usr/lib/R/lib/libR.so(Rf_applyClosure+0x2ac)[0xb7cc9e5c]
>> /usr/lib/R/lib/libR.so(Rf_eval+0x349)[0xb7cc61d9]
>> /usr/lib/R/lib/libR.so(Rf_applyClosure+0x2ac)[0xb7cc9e5c]
>> /usr/lib/R/lib/libR.so(Rf_eval+0x349)[0xb7cc61d9]
>> /usr/lib/R/lib/libR.so[0xb7c75b89]
>> /usr/lib/R/lib/libR.so(R_ToplevelExec+0xb8)[0xb7c763b8]
>> /usr/lib/R/lib/libR.so(R_tryEval+0x3e)[0xb7c7643e]
>>
>> /usr/lib/R/site-library/RGtk2/libs/RGtk2.so(R_GClosureMarshal+0x86)[0xb6ff18c6]
>> /usr/lib/libgobject-2.0.so.0(g_closure_invoke+0x129)[0xb68a7759]
>> /usr/lib/libgobject-2.0.so.0[0xb68bbd1d]
>> /usr/lib/libgobject-2.0.so.0(g_signal_emit_valist+0x8c6)[0xb68bd916]
>> /usr/lib/libgobject-2.0.so.0(g_signal_emit+0x29)[0xb68bdc59]
>> /usr/lib/libgtk-x11-2.0.so.0(gtk_button_clicked+0x8a)[0xb6bf301a]
>> /usr/lib/libgtk-x11-2.0.so.0[0xb6bf4b7e]
>>
>> /usr/lib/libgobject-2.0.so.0(g_cclosure_marshal_VOID__VOID+0x4f)[0xb68b4a4f]
>> /usr/lib/libgobject-2.0.so.0[0xb68a6079]
>> /usr/lib/libgobject-2.0.so.0(g_closure_invoke+0x129)[0xb68a7759]
>> /usr/lib/libgobject-2.0.so.0[0xb68bb975]
>> /usr/lib/libgobject-2.0.so.0(g_signal_emit_valist+0x8c6)[0xb68bd916]
>> /usr/lib/libgobject-2.0.so.0(g_signal_emit+0x29)[0xb68bdc59]
>> /usr/lib/libgtk-x11-2.0.so.0(gtk_button_released+0x8a)[0xb6bf30aa]
>> /usr/lib/libgtk-x11-2.0.so.0[0xb6bf30d1]
>> /usr/lib/libgtk-x11-2.0.so.0[0xb6ccc8d4]
>> /usr/lib/libgobject-2.0.so.0[0xb68a6079]
>> /usr/lib/libgobject-2.0.so.0(g_closure_invoke+0x129)[0xb68a7759]
>> /usr/lib/libgobject-2.0.so.0[0xb68bbea0]
>> /usr/lib/libgobject-2.0.so.0(g_signal_emit_valist+0x5fe)[0xb68bd64e]
>> /usr/lib/libgobject-2.0.so.0(g_signal_emit+0x29)[0xb68bdc59]
>> /usr/lib/libgtk-x11-2.0.so.0[0xb6deb667]
>> /usr/lib/libgtk-x11-2.0.so.0(gtk_propagate_event+0xc1)[0xb6cc5b21]
>> /usr/lib/libgtk-x11-2.0.so.0(gtk_main_do_event+0x2b8)[0xb6cc6d88]
>> /usr/lib/libgdk-x11-2.0.so.0[0xb6b3fa9a]
>> /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x178)[0xb681fbf8]
>> /usr/lib/libglib-2.0.so.0[0xb6822e5e]
>> /usr/lib/libglib-2.0.so.0(g_main_context_iteration+0x6c)[0xb68233ac]
>> /usr/lib/libgtk-x11-2.0.so.0(gtk_main_iteration+0x34)[0xb6cc70d4]
>>
>> /usr/lib/R/site-library/RGtk2/libs/RGtk2.so(R_gtk_eventHandler+0x19)[0xb6f9fb19]
>> /usr/lib/R/lib/libR.so(R_runHandlers+0x46)[0xb7db9586]
>> /usr/lib/R/lib/libR.so[0xb7dba98f]
>> /usr/lib/R/lib/libR.so(R_ReadConsole+0x35)[0xb7db7945]
>> /usr/lib/R/lib/libR.so(Rf_ReplIteration+0x42b)[0xb7cea63b]
>> /usr/lib/R/lib/libR.so(run_Rmainloop+0x102)[0xb7cea7b2]
>> /usr/lib/R/lib/libR.so(Rf_mainloop+0x1c)[0xb7cea80c]
>> /usr/lib/R/bin/exec/R(main+0x46)[0x8048776]
>> /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb7ac1450]
>> ======= Memory map: ========
>> 08048000-08049000 r-xp 00000000 08:02 288844 /usr/lib/R/bin/exec/R
>> 08049000-0804a000 rw-p 00000000 08:02 288844 /usr/lib/R/bin/exec/R
>> 0804a000-08ee1000 rw-p 0804a000 00:00 0 [heap]
>> b6387000-b6418000 r--p 00000000 08:02 261255
>> /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf
>> b6418000-b641a000 r-xp 00000000 08:02 188205
>> /usr/lib/pango/1.6.0/modules/pango-basic-fc.so
>> b641a000-b641b000 rw-p 00001000 08:02 188205
>> /usr/lib/pango/1.6.0/modules/pango-basic-fc.so
>> b641b000-b6421000 r--s 00000000 08:02 187720
>> /var/cache/fontconfig/945677eb7aeafAborted
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed 06 Aug 2008 - 13:50:48 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 06 Aug 2008 - 14:36:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive