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

SD-4452 Gimli on ARM #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

SD-4452 Gimli on ARM #2

wants to merge 4 commits into from

Conversation

kkelley1
Copy link
Collaborator

@kkelley1 kkelley1 commented Nov 6, 2024

No description provided.

Comment on lines +324 to +328
if (!sym && !strncmp(obj, "libpthread.", strlen("libpthread."))) {
/* not found in libpthread */
/* glibc 2.34 (e.g. RHEL9 and above) moved libpthread symbols to libc */
sym = gimli_sym_lookup(ph, "libc.so.6", name);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the patch in gimli.spec.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gimli is a public repo on github. Are we sure we want to make this change also public?
A safer option is to create a patch file, but keep the source code intact. Then conditionally apply the patch in gimli.spec. This could help us avoiding pushing the change into the public repo, and rebuild/alter the code for other platforms.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know why it's public? Could we make it private?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gimli itself is public because we open sourced it long ago (maybe in the omniti days? but definitely by the message systems days) for others to use and benefit from, because that's how we did things back then.

This repo is different from mine, which I think was a fork of the one that got published at OmniTI Labs (now also defunct), and yours is missing some (admittedly NOP) activity from 2012. You can find my version of the repo at:

https://github.com/wez/gimli/

There are also a number of changes I made to my fork in 2013 for darwin/intel in there that you probably don't care about. Those changes enabled the use of gimli in https://github.com/facebook/watchman back then although that project no longer uses gimli any more.

printf("sym_lookup: %s => " PTRFMT "\n", name, sym ? sym->addr : 0);
printf("sym_lookup: %s => " PTRFMT "\n", name, find.sym ? find.sym->addr : 0);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bug in the original code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks; I've applied this to my fork!

@@ -11,7 +11,7 @@ AC_C_BIGENDIAN
CFLAGS=`echo $CFLAGS | sed -e 's/-O2//;'`
CFLAGS="-D_REENTRANT $CFLAGS"
if test "$GCC" == "yes" ; then
CFLAGS="$CFLAGS -Wmissing-prototypes -Wformat"
CFLAGS="$CFLAGS -Wmissing-prototypes -Wformat -I/opt/msys/3rdParty/include"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the same context of @juliebin's comment below: https://github.com/SparkPost/gimli/pull/2/files#r1831155126, this -I option would mean only Momo dev boxes or those installed with msys-*-devel packages would be able to configure-and-build Gimli, did I get it right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually "safe" for machines without those packages installed: -I bogus has no practical effect. This sort of change is however generally a bad thing to put into something like configure.ac though, because it can have surprising or unexpected effects on systems that might have the packages installed.

For example, if you still have or use the GRUP stuff to build your rpm distribution for ecelerity, hard coding this sort of path can cause the build to fail if you have an older version of ecelerity installed while trying to build a new/current version of your package distribution.

This sort of thing is generally better for the build environment to put into $CPPFLAGS when it calls configure than to hard code directly into configure here.

@@ -35,6 +35,10 @@ case $host in
RLDPATH="-R"
DARWIN_DSYMUTIL="dsymutil -o .libs/wedgie.dSYM .libs/wedgie ; dsymutil -o .libs/libgimli.0.dylib.dSYM .libs/libgimli.0.dylib"
;;
*aarch64*linux*)
CORONER_LDFLAGS="-lthread_db -lpthread -L/opt/msys/3rdParty/lib64 -lunwind-ptrace -lunwind-generic"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above for the -L option

Copy link

@dkoerichbird dkoerichbird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am right and the baseline of this PR isn't synchronized with the 1.2.6 tag in the Mercurial repo, then I'd propose either (a) to rebase this GitHub with the tip of that foreign repo, or (b) to move these changes on top of there.

wez added a commit to wez/gimli that referenced this pull request Nov 7, 2024
reported in SparkPost/gimli#2 which
may not remain public, so I'm applying it here.
Copy link
Contributor

@wez wez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure how or why GitHub notified me about this particular version of the gimli repo, but it did, and it was a nice distraction this particular evening.

I have mostly conceptual comments: you almost certainly do not care about them and do not need to listen to me about them.

They are from the perspective and concept of "gimli is an open source and generally applicable piece of software".

It was true that it was used in at least two or maybe three projects from companies other than Message Systems for a while, but I suspect that only you are using it in earnest anywhere now, so really no one other than you will be practically impacted by any changes you make here.

(and: Hi @juliebin! I hope you are well!)

{
char cmd[100];
sprintf(cmd, "ps -L -o lwp=,comm= -p %d", proc->pid);
FILE *fp = popen(cmd, "r");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an expensive way to resolve the thread names, and is likely incorrect on !linux systems.

I would recommend instead reading /proc/PID/comm to get the thread name of an individual process on linux, and reading the directory /proc/PID/task/TID/comm to enumerate the threads and their names on linux.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turns out that I implemented it this way in 2013: wez/gimli@9b9e539

}

char cmd[100];
sprintf(cmd, "addr2line %lx -s -e /opt/msys/ecelerity/sbin/ecelerity", addr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize that the goals you have now are not the same as the goals when I created this software, but: the original reasons for gimli to exist included that the target system could not be guaranteed to have developer tools installed, and in fact, might be mandated to never have them available.

This particular change both requires developer tools and assumes that the only program it will be used with is ecelerity.

While that may be true for the only way that you deploy this software today, it renders the open source version of gimli unusable with any other software.

There may not be much of it out there today, so this is likely just a technicality now.

From a "keeping the open source project usable in its original spirit" perspective, this change is not ideal, but it's been 12 years and likely nobody other than me cares.

Comment on lines +324 to +328
if (!sym && !strncmp(obj, "libpthread.", strlen("libpthread."))) {
/* not found in libpthread */
/* glibc 2.34 (e.g. RHEL9 and above) moved libpthread symbols to libc */
sym = gimli_sym_lookup(ph, "libc.so.6", name);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gimli itself is public because we open sourced it long ago (maybe in the omniti days? but definitely by the message systems days) for others to use and benefit from, because that's how we did things back then.

This repo is different from mine, which I think was a fork of the one that got published at OmniTI Labs (now also defunct), and yours is missing some (admittedly NOP) activity from 2012. You can find my version of the repo at:

https://github.com/wez/gimli/

There are also a number of changes I made to my fork in 2013 for darwin/intel in there that you probably don't care about. Those changes enabled the use of gimli in https://github.com/facebook/watchman back then although that project no longer uses gimli any more.

@@ -11,7 +11,7 @@ AC_C_BIGENDIAN
CFLAGS=`echo $CFLAGS | sed -e 's/-O2//;'`
CFLAGS="-D_REENTRANT $CFLAGS"
if test "$GCC" == "yes" ; then
CFLAGS="$CFLAGS -Wmissing-prototypes -Wformat"
CFLAGS="$CFLAGS -Wmissing-prototypes -Wformat -I/opt/msys/3rdParty/include"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually "safe" for machines without those packages installed: -I bogus has no practical effect. This sort of change is however generally a bad thing to put into something like configure.ac though, because it can have surprising or unexpected effects on systems that might have the packages installed.

For example, if you still have or use the GRUP stuff to build your rpm distribution for ecelerity, hard coding this sort of path can cause the build to fail if you have an older version of ecelerity installed while trying to build a new/current version of your package distribution.

This sort of thing is generally better for the build environment to put into $CPPFLAGS when it calls configure than to hard code directly into configure here.

Comment on lines +247 to +254
#if 0 // __aarch64__ abandoned effort
uint64_t a;
if (gimli_read_mem(cur->proc, (gimli_addr_t)cur->st.pc, &a, sizeof(a)) == sizeof(a)) {
if (a == 0xd4000001d2801168) {
return 1;
}
}
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I would recommend that you delete all these various unreachable code blocks from this PR to keep things smaller and easier to reason about

printf("sym_lookup: %s => " PTRFMT "\n", name, sym ? sym->addr : 0);
printf("sym_lookup: %s => " PTRFMT "\n", name, find.sym ? find.sym->addr : 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks; I've applied this to my fork!

@wez
Copy link
Contributor

wez commented Nov 7, 2024

one of the commits in my fork is wez/gimli@1487ef8 which adds a configure option to use libunwind more directly, maybe you want to merge that and the other changes from my fork back? It's possible that it handles arm for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants