Last active
May 29, 2016 01:38
-
-
Save simark/e4994ad149db8afa6cb72d5d2ac8b00c to your computer and use it in GitHub Desktop.
Segfault when dlopening/dlclosing two instrumented .so.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "tracepoints_lol.h" | |
void | |
foo (void) | |
{ | |
tracepoint (tracepoints_lol, lol, 1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <dlfcn.h> | |
#include <assert.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
void | |
call_lib (const char *name) | |
{ | |
const char *error; | |
void *lib = dlopen (name, RTLD_NOW); | |
if (lib == NULL) | |
{ | |
printf("Error: %s\n", dlerror ()); | |
exit (1); | |
} | |
assert (lib != NULL); | |
dlerror (); | |
void (*func) (void) = dlsym (lib, "foo"); | |
error = dlerror (); | |
if (error != NULL) | |
{ | |
printf("Error: %s\n", error); | |
exit (1); | |
} | |
func (); | |
int ret = dlclose (lib); | |
if (ret != 0) | |
{ | |
printf("Error: %s\n", dlerror ()); | |
exit (1); | |
} | |
} | |
int | |
main (void) | |
{ | |
call_lib ("./liblol.so"); | |
call_lib ("./libmdr.so"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: main liblol.so libmdr.so | |
main: main.c | |
gcc -o main main.c -ldl -g3 -O0 | |
liblol.so: lol.o tracepoints_lol.o | |
gcc -shared -o liblol.so lol.o tracepoints_lol.o -llttng-ust | |
lol.o: lol.c tracepoints_lol.h | |
gcc -fpic -c lol.c -g3 -O0 | |
libmdr.so: mdr.o tracepoints_mdr.o | |
gcc -shared -o libmdr.so mdr.o tracepoints_mdr.o -llttng-ust | |
mdr.o: mdr.c tracepoints_mdr.h | |
gcc -fpic -c mdr.c -g3 -O0 | |
tracepoints_lol.o: tracepoints_lol.c | |
gcc -fpic -c $< -g3 -O0 -I. | |
tracepoints_mdr.o: tracepoints_mdr.c | |
gcc -fpic -c $< -g3 -O0 -I. | |
clean: | |
rm -rf *.o *.so main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "tracepoints_mdr.h" | |
void | |
foo (void) | |
{ | |
tracepoint (tracepoints_mdr, mdr, 1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE | |
#define TRACEPOINT_CREATE_PROBES | |
/* | |
* The header containing our TRACEPOINT_EVENTs. | |
*/ | |
#define TRACEPOINT_DEFINE | |
#include "tracepoints_lol.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#undef TRACEPOINT_PROVIDER | |
#define TRACEPOINT_PROVIDER tracepoints_lol | |
#undef TRACEPOINT_INCLUDE | |
#define TRACEPOINT_INCLUDE "./tracepoints_lol.h" | |
#if !defined(TRACEPOINTS_LOL_H) || defined(TRACEPOINT_HEADER_MULTI_READ) | |
#define TRACEPOINTS_LOL_H | |
#include <lttng/tracepoint.h> | |
TRACEPOINT_EVENT(tracepoints_lol, lol, | |
TP_ARGS (int, hello), | |
TP_FIELDS (ctf_integer(int, hello, hello))) | |
#endif /* TRACEPOINTS_LOL_H */ | |
#include <lttng/tracepoint-event.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE | |
#define TRACEPOINT_CREATE_PROBES | |
/* | |
* The header containing our TRACEPOINT_EVENTs. | |
*/ | |
#define TRACEPOINT_DEFINE | |
#include "tracepoints_mdr.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#undef TRACEPOINT_PROVIDER | |
#define TRACEPOINT_PROVIDER tracepoints_mdr | |
#undef TRACEPOINT_INCLUDE | |
#define TRACEPOINT_INCLUDE "./tracepoints_mdr.h" | |
#if !defined(TRACEPOINTS_MDR_H) || defined(TRACEPOINT_HEADER_MULTI_READ) | |
#define TRACEPOINTS_MDR_H | |
#include <lttng/tracepoint.h> | |
TRACEPOINT_EVENT(tracepoints_mdr, mdr, | |
TP_ARGS (int, hello), | |
TP_FIELDS (ctf_integer(int, hello, hello))) | |
#endif /* TRACEPOINTS_MDR_H */ | |
#include <lttng/tracepoint-event.h> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment