Problems with systemtap script - linux

I wanna write a small script that identifies which function is using the mmap syscall:
#! /usr/bin/env stap
probe syscall.mmap.return {
if ( execname()=="java")
printf ("%s mmap caller\n", caller())
}
But it returns:
[root#gclimo01 stap]# stap -v mmap_caller.stp
Pass 1: parsed user script and 85 library script(s) using 198360virt/26732res/2944shr kb, in 210usr/50sys/264real ms.
Pass 2: analyzed script: 1 probe(s), 4 function(s), 4 embed(s), 0 global(s) using 355384virt/51680res/4048shr kb, in 650usr/350sys/1000real ms.
Pass 3: translated to C into "/tmp/stapwIxSzq/stap_a1823a5a24071fdf3118f618597b4ab6_7801_src.c" using 352824virt/54320res/6828shr kb, in 190usr/80sys/283real ms.
/tmp/stapwIxSzq/stap_a1823a5a24071fdf3118f618597b4ab6_7801_src.c: In function 'function_caller_addr':
/tmp/stapwIxSzq/stap_a1823a5a24071fdf3118f618597b4ab6_7801_src.c:646: error: dereferencing pointer to incomplete type
make[1]: *** [/tmp/stapwIxSzq/stap_a1823a5a24071fdf3118f618597b4ab6_7801_src.o] Error 1
make: *** [_module_/tmp/stapwIxSzq] Error 2
WARNING: make exited with status: 2
Pass 4: compiled C into "stap_a1823a5a24071fdf3118f618597b4ab6_7801.ko" in 1170usr/1120sys/2207real ms.
Pass 4: compilation failed. Try again with another '--vp 0001' option.
My systems is RHEL 6.3, Linux xxxxxxxxx 2.6.32-279.1.1.el6.x86_64 #1 SMP Wed Jun 20 11:41:22 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
any tip ?

This was http://sourceware.org/bugzilla/show_bug.cgi?id=14079, fixed in systemtap 1.8 with
commit 4107dbc2c88536c3374a68948c7344af8c8e75aa
Author: Mark Wielaard <mjw#redhat.com>
Date: Tue May 8 19:59:07 2012 +0200
PR14079 - caller() pass-4 error if no uretprobes in script
caller() is odd in that it tries to do both kernel and user caller.
There is no ucaller(). Move it into its own tapset and include the
right uprobes related structures.
* runtime/uprobes-inc.h: New include file to be included in ...
* runtime/stack.c: here and ...
* tapset/context-caller.stp: here. New tapset, with just the caller context
function, removed from ...
* tapset/context-unwind.stp: here.
* doc/SystemTap_Tapset_Reference/tapsets.tmpl: Also include context-caller.stp.

Related

Xenomai 3.1 mercury prologue failed for thread running official demo

Hello I have the following problem running a Xenomai demo: "prologue failed for thread" EINVAL
debian:~/xenomai_mercury_lib/demo$ sudo ./alchemy/altency
0"000.665| WARNING: [main] prologue failed for thread <anonymous>, EINVAL
== Sampling period: 100 us
== Test mode: periodic user-mode task
== All results in microseconds
0"000.997| WARNING: [main] prologue failed for thread alt-display-2077, EINVAL
altency: failed to create display task, code -22
What I have:
debian 10.10.0-amd64, installed inside a VirtualBox
xenomai 3.1 mercury installed and built for 32bit target
xenomai configure:
../xenomai-3.1/configure --enable-lores-clock --with-core=mercury --enable-smp --enable-pshared CFLAGS="-m32 -O2" LDFLAGS="-m32"
Maybe something is missing inside the underlying OS? Something to install?
Do you have some ideas?
Thanks a lot.

Probing a userspace process with systemtap over ebpf begin probe doesn't work

I'm trying to probe a userspace process with a begin probe that doesn't seem to do anything
begin.stp:
probe process("a.out").begin {
printf("%s %d\n", execname(), pid())
}
stp output:
[root#RHEL8 ~]# stap --bpf -v ~/begin.stp
Pass 1: parsed user script and 56 library scripts using 203356virt/48420res/12256shr/36024data kb, in 100usr/10sys/114real ms.
Pass 2: analyzed script: 2 probes, 3 functions, 0 embeds, 1 global using 204676virt/50128res/12392shr/37344data kb, in 10usr/10sys/11real ms.
Pass 3: pass skipped for stapbpf runtime in 0usr/0sys/0real ms.
Pass 4: compiled BPF into "stap_30984.bo" in 0usr/0sys/2real ms.
Pass 5: starting run.
When changing the probe to the main() function it seems to work:
function.stp
probe process("a.out").function("main") {
printf("%s %d\n", execname(), pid())
}
stap output:
[root#RHEL8 ~]# stap --bpf -v ~/222.stp
Pass 1: parsed user script and 56 library scripts using 203356virt/48364res/12200shr/36024data kb, in 290usr/50sys/404real ms.
Pass 2: analyzed script: 2 probes, 3 functions, 0 embeds, 1 global using 204676virt/50996res/13068shr/37344data kb, in 20usr/0sys/25real ms.
Pass 3: pass skipped for stapbpf runtime in 0usr/0sys/0real ms.
Pass 4: compiled BPF into "stap_31782.bo" in 0usr/0sys/3real ms.
Pass 5: starting run.
a.out 31806
a.out 31821
a.out 31827
a.out 31831
stap version
[root#RHEL8 ~]# stap --version
Systemtap translator/driver (version 4.2/0.178, rpm 4.2-6.el8)
Copyright (C) 2005-2019 Red Hat, Inc. and others
This is free software; see the source for copying conditions.
tested kernel versions: 2.6.32 ... 5.4-rc6
enabled features: AVAHI BOOST_STRING_REF DYNINST BPF JAVA PYTHON3 LIBRPM LIBSQLITE3 LIBVIRT LIBXML2 NLS NSS READLINE
After consulting the developers of system tap they opened a new bug
http://sourceware-org.1504.n7.nabble.com/Bug-bpf-26234-New-utrace-derived-probes-and-others-being-silently-ignored-by-bpf-backend-td642492.html

PHP exec(myexe) fails in PHP App, but not CLI. Fails Running Under User "apache"

I have a custom program (e.g. myexe) being executed by a web app using PHP's exec() function. It does not fail when run using the PHP CLI nor does myexe fail when run from the command line with me as a user. I have built myexe so that there are no memory issues when profiled using valgrind. myexe is about 26MB in size.
To simplify the situation, I have run myexe on the command line under the user 'apache' and reproduced the failure.
su -s /bin/sh apache -c "/usr/local/bin/myexe parm1 parm2..."
==> Segmentation fault (core dumped)
BUT when I change the user to myself and run the same command above, it works.
su -s /bin/sh mike -c "/usr/local/bin/myexe parm1 parm2..."
==> WORKS
Here's the error from the system log file:
Jul 9 18:26:15 DEVSTN-1 kernel: myexe[27352]: segfault at 7fffa2bf9ff8 ip 0000000000410324 sp 00007fffa2bfa000 error 6 in myexe[400000+5ae000]
Jul 9 18:26:16 DEVSTN-1 abrt[27353]: Saved core dump of pid 27352 (/usr/local/bin/myexe) to /var/spool/abrt/ccpp-2015-07-09-18:26:15-27352 (13631488 bytes)
Jul 9 18:26:16 DEVSTN-1 abrtd: Directory 'ccpp-2015-07-09-18:26:15-27352' creation detected
Jul 9 18:26:17 DEVSTN-1 abrtd: Executable '/usr/local/bin/myexe' doesn't belong to any package and ProcessUnpackaged is set to 'no'
Jul 9 18:26:17 DEVSTN-1 abrtd: 'post-create' on '/var/spool/abrt/ccpp-2015-07-09-18:26:15-27352' exited with 1
Jul 9 18:26:17 DEVSTN-1 abrtd: Deleting problem directory '/var/spool/abrt/ccpp-2015-07-09-18:26:15-27352'
My configuration:
CentOS6 2.6.32-504.23.4.el6.x86_64
Apache/2.2.15 (CentOS)
PHP Version 5.3.3
Am I correct with assuming that PHP has nothing to do with the error?
What should I do next?
Correct; PHP has nothing to do with the error. This is a segmentation fault caused by invalid memory access (either overflowing a buffer, or accessing already-freed memory) in myexe. It seems to have saved a core dump to /var/spool/abrt/ccpp-2015-07-09-18:26:15-27352, so, try debugging with GDB:
gdb /usr/local/bin/myexe -c /var/spool/abrt/ccpp-2015-07-09-18:26:15-27352
(gdb) bt
And try to see where the executable is failing. To get useful output, it will need to be compiled with debugging symbols. If it doesn't fail running as root or a different user, or running in an interactive terminal, I'd look for bugs that could be triggered by being unable to open a file, unable to read an expected environment variable, etc. to help isolate your problem.
Running the executable under strace might help figure out what's going on as well.
Found the problem by entering a bash shell user user apache and running the program using gdb.
Turns out myexe was trying to create a directory under the user's home dir (/home/apache) which doesn't exist.
What helped me was knowing how to start a shell under a different user and using gdb.
Here's the command to start a shell under another user (apache):
su -s /bin/bash apache

Patch ArchLinux ARM with grsecurity

I would like to patch my ArchLinux for Raspberry Pi with grsecurity.
This is what I've done so far:
I've downloaded the linux-raspberry directory (with the PKGBUILD) available here
https://github.com/archlinuxarm/PKGBUILDs/tree/master/core/linux-raspberrypi
I used the linux-raspberry directory.
There, I wget the patch: http://grsecurity.net/stable/grsecurity-3.0-3.2.58-201405112002.patch
To continue, I've applied the patch in the PKGBUILD, in the prepare() function:
patch -p1 < "${srcdir}/grsecurity-3.0-3.2.58-201405112002.patch"
Then:
makepkg
Unfortunately, at the line of the patch, I got an:
==> ERROR: A failure occurred in prepare().
I've applied the patch manually and I got things like that:
Hunk #10 succeeded at 3232 (offset 440 lines).
Hunk #11 succeeded at 3242 (offset 440 lines).
Hunk #12 FAILED at 2816.
1 out of 12 hunks FAILED -- saving rejects to file virt/kvm/kvm_main.c.rej
This file contains :
--- virt/kvm/kvm_main.c
+++ virt/kvm/kvm_main.c
## -2816,9 +2832,6 ##
register_syscore_ops(&kvm_syscore_ops);
- kvm_preempt_ops.sched_in = kvm_sched_in;
- kvm_preempt_ops.sched_out = kvm_sched_out;
-
kvm_init_debug();
return 0;
That is probably because I used a wrong version of grsecurity for my kernel which is :
3.12.20-1-ARCH
If you have any idea if it might be this, or something else, please let me know

JVM crashes when running SOAPUI on Ubuntu

I just downloaded SOAPUI 4.0.1 and tried to run it in Ubuntu 11.10. I run the file soapui.sh. The application started up and the window actually appeared, but then after a few seconds it closed. Looking at the terminal I saw that the JVM crashed. Below are the details of the error:
(process:4183): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.30.0/./gobject/gtype.c:2708: You forgot to call g_type_init()
(process:4183): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
(process:4183): GLib-GObject-CRITICAL **: g_object_ref: assertion `G_IS_OBJECT (object)' failed
Problematic frame:
C [libgconf-2.so.4+0x15b99] gconf_enum_to_string+0xd59
Can anyone help? Thanks.
Look here: http://www.eviware.com/forum/viewtopic.php?f=13&t=7736
Look in ..../soapui-4.0.1/bin/soapui.sh:
#uncomment to disable browser component
#JAVA_OPTS="$JAVA_OPTS -Dsoapui.jxbrowser.disable=true" <- uncomment this line
if you are usising soapui.sh to start soapUI. If you used installer and using launcher than
in soapUI-*.vmoptions add -Dsoapui.jxbrowser.disable=true
that should do the trick.
I also have the same issue
--
DUMP
...
# JRE version: 6.0_33-b03
# Java VM: Java HotSpot(TM) Server VM (20.8-b03 mixed mode linux-x86 )
# Problematic frame:
# C [libgconf-2.so.4+0x176aa] __float128+0x176aa
...
OS:Fedora release 16 (Verne)
uname:Linux 3.3.2-6.fc16.i686 #1 SMP Sat Apr 21 13:23:12 UTC 2012 i686
libc:glibc 2.14.90 NPTL 2.14.90
...
--
This jxbrowser...jar is working with xulrunner-2.8...jar and native code doesn't full compatible with your OS dependencies.
jxbrowser it's used for 'HTML rendering' but works also without it.
--
It works also in FC16

Resources