Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] Regression test for EGL-glibc TLS conflict #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions libhybris/hybris/tests/test_glesv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@
#include <math.h>
#include <stddef.h>

/* Regression test: make sure that there's no conflict between
* the TLS (thread-local storage) slots used via libEGL/bionic
* and the TLS space allocated by the host toolchain. The array
* declared here should remain unchanged regardless of GL activity.
* Since this array is the first __thread storage declared in the main
* program, glibc will allocate it before any others.
*/
#define SLOT_FILLER (void *) 0x11122111 /* arbitrary non-zero value */
#define S SLOT_FILLER
__thread void *tls_space[64] = {
S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
};
#undef S

const char vertex_src [] =
" \
attribute vec4 position; \
Expand Down Expand Up @@ -175,6 +192,18 @@ int main(int argc, char **argv)
printf("terminated\n");
android_dlclose(baz);
#endif

int bad_tls = 0;
for (i=0; i<64; ++i) {
if (tls_space[i] != SLOT_FILLER) {
printf("TLS array slot %d polluted: %p\n", i, tls_space[i]);
bad_tls++;
}
}
if (bad_tls)
return 1;

return 0;
}

// vim:ts=4:sw=4:noexpandtab