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

Tilp: Coredump on unsupported library versions #74

Open
aarondill opened this issue Feb 21, 2024 · 4 comments
Open

Tilp: Coredump on unsupported library versions #74

aarondill opened this issue Feb 21, 2024 · 4 comments

Comments

@aarondill
Copy link

When an unsupported library version is detected, tilp_init exits early and functions like tilp_paths_init() never get called, leading to null values being passed to Gtk later.

1 of 2 options should be chosen to avoid segfaulting:

  1. Remove the return 1 statements (just warn on stderr) -- This is only an option if it's possible to continue execution without the correct libraries (albeit a User Error). It seems to be?
diff
diff --git a/tilp/trunk/src/tilp_main.c b/tilp/trunk/src/tilp_main.c
index 835e041..7299209 100644
--- a/tilp/trunk/src/tilp_main.c
+++ b/tilp/trunk/src/tilp_main.c
@@ -120,25 +120,25 @@ int tilp_init(int *argc, char ***argv)
 	if (strcmp(ticonv_version_get(), TILP_REQUIRES_LIBTICONV_VERSION) < 0)
 	{
 		tilp_critical(_("libticonv library version is %s but %s mini required.\n"), ticonv_version_get(), TILP_REQUIRES_LIBTICONV_VERSION);
-		return 1;
 	}
 
 	if (strcmp(tifiles_version_get(), TILP_REQUIRES_LIBTIFILES2_VERSION) < 0)
 	{
 		tilp_critical(_("libtifiles library version is %s but %s mini required.\n"), tifiles_version_get(), TILP_REQUIRES_LIBTIFILES2_VERSION);
-		return 1;
 	}
 
 	if (strcmp(ticables_version_get(), TILP_REQUIRES_LIBTICABLES2_VERSION) < 0)
 	{
 		tilp_critical(_("libticables library version is %s but %s mini required.\n"), ticables_version_get(), TILP_REQUIRES_LIBTICABLES2_VERSION);
-		return 1;
 	}
 
 	if (strcmp(ticalcs_version_get(), TILP_REQUIRES_LIBTICALCS2_VERSION) < 0)
 	{
 		tilp_critical(_("libticalcs library version is %s but %s mini required.\n"), ticalcs_version_get(), TILP_REQUIRES_LIBTICALCS2_VERSION);
-		return 1;
 	}
 
 	/* Initialize platform independant paths */
  1. Exit when tilp_init() indicates failure:
diff
diff --git a/tilp/trunk/src/main.c b/tilp/trunk/src/main.c
index bc007ab..1fee5a7 100644
--- a/tilp/trunk/src/main.c
+++ b/tilp/trunk/src/main.c
@@ -120,7 +120,7 @@ int main(int argc, char *argv[])
 	g_setenv("G_MESSAGES_DEBUG", "all", /* overwrite = */ FALSE);
 
 	/* Init the tilp core */
-	tilp_init(&argc, &argv);
+	if(tilp_init(&argc, &argv)) exit(1);
 
 	/* Init GTK+ */
 	gtk_init(&argc, &argv);

Having tested both of these with invalid library versions, I prefer the former, as it would allow me to continue to use the git HEAD (I'm on Arch and the libraries are not available yet), however, the later would help prevent bug reports due to outdated dependencies.

libticonv library version is 1.1.5 but 1.1.6 mini required.
libtifiles library version is 1.1.7 but 1.1.8 mini required.
libticables library version is 1.3.5 but 1.3.6 mini required.
@aarondill
Copy link
Author

I'm happy to submit a PR with either of the above patches (or another) if you would like

@aarondill aarondill changed the title Coredump on unsupported library versions Tilp: Coredump on unsupported library versions Feb 21, 2024
@debrouxl
Copy link
Owner

Thanks for the report. It's interesting that this one doesn't get reported more often... do you have multiple versions of libti* in your LD_LIBRARY_PATH ?

Running TILP with outdated library dependencies is a fatal error, in that a subset of the functionality will be unavailable. Since there's a need to fiddle with the library version checking code anyway... I think that the right way to fix this is to use a proper version comparison routine (which strcmp() isn't: 1.1.10 < 1.1.9), and report all outdated libraries in one go, before exiting the program cleanly.

@aarondill
Copy link
Author

does C / GTK supply a version checking function? I tried a google search and couldn't find anything that looked promising?

@debrouxl
Copy link
Owner

There had to be a version comparison routine in package managers or below sort -V. A little digging around returns https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/strverscmp.c and https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/filevercmp.c , both of which are generic... but eww, all the more portability concerns mandate integrating a local copy of these LGPL'ed functions.

For simple version numbers made of 3 numeric elements, sscanf() would work... that is, if it handled numeric overflow correctly. I was reminded by comments on StackOverflow that it doesn't...

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

No branches or pull requests

2 participants