Commit 053afd28 authored by Yuanle Song's avatar Yuanle Song
Browse files

update info on the segfault on RHEL

I will leave it for another day. can't locate problem now.
parent f7400c92
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -102,7 +102,6 @@ startup(GApplication *app,
	/* show panel, wait 3s, then hide panel and exit app */
	err = NULL;
	const gchar *const candidates[] = {"第一个", "第二个", "第三个"};
	/* g_message("first: %s", candidates[0]); */
	GVariant *hints = NULL;
	GVariantBuilder b = {0};
	g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));
+102 −3
Original line number Diff line number Diff line
@@ -213,7 +213,7 @@ They don't work properly in Wayland.

* current                                                             :entry:
** 
** 2023-08-16 bug: ./build/zero-panel-client-demo segfault on RHEL9.
** 2023-08-16 bug: ./build/zero-panel-client-demo with -O2 segfault on RHEL9.
- it runs fine on lat21. but has a few warnings. fix the warnings.
  #+BEGIN_SRC sh
    sylecn@lat21:~/projects/zero-panel$ ./build/zero-panel-client-demo
@@ -230,6 +230,7 @@ They don't work properly in Wayland.
    ,** Message: 12:11:41.111: call Hide() okay
    ,** Message: 12:11:41.111: shutdown()
  #+END_SRC

- search: GLib-CRITICAL assert how to debug get source code line?

  rm -rf build/
@@ -240,7 +241,7 @@ They don't work properly in Wayland.

  env G_DEBUG=fatal-criticals ./build/zero-panel-client-demo

- I think the Chinese char* literal is most suspicious.
- INVALID I think the Chinese char* literal is most suspicious.
  try use ascii string there.
  yes. debugoptimized build warning is gone when only use ascii string.

@@ -248,7 +249,10 @@ They don't work properly in Wayland.

  all char* is assumed to be utf-8. it is supported out of the box.

- I got a minimal reproducible demo.
  // segfault also happen in -O2 with ascii literal. it's not utf-8 string
  issue.

- FIXED I got a minimal reproducible demo. // this is another locale issue. fixed.
  #+BEGIN_SRC c
    const gchar* first = "第一个";
    g_assert_true(g_utf8_validate(first, -1, NULL));
@@ -283,6 +287,101 @@ They don't work properly in Wayland.
  // good.

- warning still persist after adding setlocale() call.
  new code still segfault on RHEL9.

  on RHEL9,
  debug build doesn't segfault.
  has a warning.
  #+BEGIN_SRC sh
    ,** (zero-panel-client-demo:36293): WARNING **: 14:43:15.167: call ShowCandidates() failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name is not activatable
  #+END_SRC
  the demo requires zero-panel service running.

  when zero-panel service is running. the program in debug mode runs fine in
  RHEL9.

  debugoptimized still segfault.

  #+BEGIN_SRC sh
    or help, type "help".
    Type "apropos word" to search for commands related to "word"...
    Reading symbols from ./build/zero-panel-client-demo...
    (gdb) run
    Starting program: /home/sylecn/fromsource/zero-panel/build/zero-panel-client-demo 
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib64/libthread_db.so.1".
    [New Thread 0x7fffea1ff640 (LWP 37881)]
    [New Thread 0x7fffe99fe640 (LWP 37882)]

    Thread 1 "zero-panel-clie" received signal SIGSEGV, Segmentation fault.
    0x00007ffff7cce680 in g_utf8_validate () from /lib64/libglib-2.0.so.0
    Missing separate debuginfos, use: dnf debuginfo-install glib2-2.68.4-6.el9.x86_64 glibc-2.34-60.el9.x86_64 libblkid-2.37.4-11.el9_2.x86_64 libffi-3.4.2-7.el9.x86_64 libmount-2.37.4-11.el9_2.x86_64 libselinux-3.5-1.el9.x86_64 pcre-8.44-3.el9.3.x86_64 pcre2-10.40-2.el9.x86_64
    (gdb) 
  #+END_SRC

  sudo dnf debuginfo-install glib2-2.68.4-6.el9.x86_64 glibc-2.34-60.el9.x86_64 \
    libblkid-2.37.4-11.el9_2.x86_64 libffi-3.4.2-7.el9.x86_64 \
    libmount-2.37.4-11.el9_2.x86_64 libselinux-3.5-1.el9.x86_64 \
    pcre-8.44-3.el9.3.x86_64 pcre2-10.40-2.el9.x86_64 \
    zlib-1.2.11-39.el9.x86_64

- gdb show error is in
  0x00007ffff7cce680 in g_utf8_validate () from /lib64/libglib-2.0.so.0

  #+BEGIN_SRC sh
    Thread 1 "zero-panel-clie" received signal SIGSEGV, Segmentation fault.
    g_utf8_validate (str=0x1 <error: Cannot access memory at address 0x1>, 
	max_len=-1, end=0x0) at ../glib/gutf8.c:1671
    1671	g_utf8_validate (const char   *str,
  #+END_SRC

  now this is clear.
  str=0x1 <error: Cannot access memory at address 0x1>

  0x1 doesn't look like a proper memory address.

  C Language, cannot access memory at 0x1
  http://computer-programming-forum.com/17-c-language/91171078d803c0ab.htm

  #+begin_quote
  Almost certainly an uninitialised pointer
  #+end_quote

  #+begin_quote
  The usual cause of this type of problem is misusing, or abusing, a pointer.
  #+end_quote

  on rh901, in build/ dir.
  meson configure --optimization=1
  no error when running ./build/zero-panel-client-demo
  unicode literal in source code is no issue.

  meson configure --optimization=2
  segfault.

  confirmed it's gcc optimization issue.
  my code has problem when compiled with gcc -O2.

  c - signal SIGSEGV caused by the -O2 flag - Stack Overflow
  https://stackoverflow.com/questions/70629842/signal-sigsegv-caused-by-the-o2-flag

  debugging - What are best practices for finding a bug in a C program that only shows up in optimized build - Stack Overflow
  https://stackoverflow.com/questions/6455347/what-are-best-practices-for-finding-a-bug-in-a-c-program-that-only-shows-up-in-o

  valgrind

  just use valgrind to run it on lat21. it will reveal the problem.

- use valgrind to find bugs.

  ==9852==    by 0x10BF77: zero_panel_call_show_candidates_sync (zero-panel-generated-fixed.c:901)

  I can't see what's wrong there.
  all passed in arguments are initialized.

- problems
  - I can't install valgrind on rh901. license issue.
    VM is not registered properly.

** 2023-08-16 what's new in gtk4? should I upgrade?
- Gtk – 4.0: Migrating from GTK 3.x to GTK 4