Bug 15170 - [4.3 M2 RC1] segfault for createrepo_c on beaglebone and qemuarm
Summary: [4.3 M2 RC1] segfault for createrepo_c on beaglebone and qemuarm
Status: VERIFIED FIXED
Alias: None
Product: General Runtime
Classification: Runtime
Component: General Runtime (show other bugs)
Version: 4.3
Hardware: BeagleBone arm
: Undecided normal
Target Milestone: 4.3 M2
Assignee: Richard Purdie
QA Contact: Yi Zhao
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2023-07-24 08:19 UTC by Yi Zhao
Modified: 2023-07-28 04:59 UTC (History)
7 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: Regression (Used to work)
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments
proposed fix. (2.70 KB, patch)
2023-07-26 19:30 UTC, Khem Raj
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yi Zhao 2023-07-24 08:19:39 UTC
Image Location: https://autobuilder.yocto.io/pub/releases/yocto-4.3_M2.rc1/machines/beaglebone-yocto/

Poky git rev: f73ae292bc0b92df3cb76c6e8b220f18630f6bc7


Steps:
1. Deploy rootfs image and boot up.
2. Install createrepo-c:
   $ rpm -ivh createrepo-c-0.21.1-r0.cortexa8hf_neon.rpm
3. Run creatrepo_c to create a local repo:
   $ mkdir localrepo
   $ createrepo_c ./localrepo
   Directory walk started
   Directory walk done - 0 packages
   Temporary output repo path: ./localrepo/.repodata/
   Preparing sqlite DBs
   Pool started (with 5 workers)
   Pool finished
   Segmentation fault



This issue happens on beaglebone-yocto and qemuarm. I also tested on qemux86-64 and qemuarm64, there is no such issue.
Comment 1 Richard Purdie 2023-07-25 10:30:41 UTC
sqlite regressing on 32 bit arm?
Comment 2 Richard Purdie 2023-07-26 16:20:06 UTC
I reverted various upgrades back to 3.40.1 and it still segfaults
Comment 3 Richard Purdie 2023-07-26 17:09:26 UTC
I've confirmed it is the time64.inc changes that trigger the segfault
Comment 4 Richard Purdie 2023-07-26 18:52:45 UTC
Thread 1 "createrepo_c" received signal SIGSEGV, Segmentation fault.
__GI_strlen () at ../sysdeps/arm/armv6t2/strlen.S:126
126	../sysdeps/arm/armv6t2/strlen.S: No such file or directory.
(gdb) bt
#0  __GI_strlen () at ../sysdeps/arm/armv6t2/strlen.S:126
#1  0xb6dd8434 in __printf_buffer (buf=buf@entry=0xbefff5f0, format=format@entry=0xbefff708 "", ap=..., mode_flags=mode_flags@entry=2)
    at vfprintf-process-arg.c:435
#2  0xb6decd0e in __vasprintf_internal
    (result_ptr=result_ptr@entry=0xbefff708, format=format@entry=0xbefff708 "", args=..., mode_flags=mode_flags@entry=2) at vasprintf.c:102
#3  0xb6e5ae38 in __vasprintf_chk (result_ptr=result_ptr@entry=0xbefff708, flag=flag@entry=1, format=format@entry=0xbefff708 "", ap=...)
    at vasprintf_chk.c:36
#4  0xb6f401c4 in vasprintf (__ap=..., __fmt=<optimized out>, __ptr=0xbefff708) at /usr/include/bits/stdio2.h:169
#5  g_vasprintf (string=string@entry=0xbefff708, format=format@entry=0x0, args=...) at /usr/src/debug/glib-2.0/1_2.76.4-r0/glib/gprintf.c:340
#6  0xb6f16fb0 in g_strdup_vprintf (format=format@entry=0x0, args=..., args@entry=...) at /usr/src/debug/glib-2.0/1_2.76.4-r0/glib/gstrfuncs.c:553
#7  0xb6f17000 in g_strdup_printf (format=0xb6fd0e68 "%s%jd.%s.%ld%s") at /usr/src/debug/glib-2.0/1_2.76.4-r0/glib/gstrfuncs.c:583
#8  0xb6fbf8d6 in cr_append_pid_and_datetime (str=<optimized out>, suffix=suffix@entry=0x0) at /usr/src/debug/createrepo-c/0.21.1-r0/src/misc.c:1501
#9  0x00405962 in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/createrepo-c/0.21.1-r0/src/createrepo_c.c:2473
Comment 5 Richard Purdie 2023-07-26 19:01:57 UTC
Compile log has a corresponding:

/media/build/poky/build/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/createrepo-c/0.21.1-r0/git/src/misc.c: In function 'cr_append_pid_and_datetime':
/media/build/poky/build/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/createrepo-c/0.21.1-r0/git/src/misc.c:1501:49: warning: format '%ld' expects argument of type 'long int', but argument 5 has type '__suseconds
64_t' {aka 'long long int'} [-Wformat=]
 1501 |     gchar *result = g_strdup_printf("%s%jd.%s.%ld%s",
      |                                               ~~^
      |                                                 |
      |                                                 long int
      |                                               %lld
......
 1505 |                                     tv.tv_usec,
      |                                     ~~~~~~~~~~   
      |                                       |
      |                                       __suseconds64_t {aka long long int}
Comment 6 Richard Purdie 2023-07-26 19:12:56 UTC
Also suspect we may need to fix:

/media/build/poky/build/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/createrepo-c/0.21.1-r0/git/src/xml_dump_repomd.c
/media/build/poky/build/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/createrepo-c/0.21.1-r0/git/src/xml_dump_repomd.c: In function 'cr_xml_dump_repomd_body':
/media/build/poky/build/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/createrepo-c/0.21.1-r0/git/src/xml_dump_repomd.c:146:41: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'time_t' {aka 'long long int'} [-Wformat=]
  146 |         gchar *rev = g_strdup_printf("%ld", time(NULL));
      |                                       ~~^   ~~~~~~~~~~
      |                                         |   |
      |                                         |   time_t {aka long long int}
      |                                         long int
      |                                       %lld


and

/media/build/poky/build/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/createrepo-c/0.21.1-r0/git/src/createrepo_c.c: In function 'duplicates_warning':
/media/build/poky/build/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/createrepo-c/0.21.1-r0/git/src/createrepo_c.c:643:17: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'gint64' {aka 'long long int'} [-Wformat=]
  643 |       g_warning("    Sourced from location: \'%s\', build timestamp: %ld%s",
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  644 |                 location.location,
  645 |                 location.pkg->time_build,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~
      |                             |
      |                             gint64 {aka long long int}
/media/build/poky/build/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/createrepo-c/0.21.1-r0/recipe-sysroot/usr/include/glib-2.0/glib/gmessages.h:356:32: note: in definition of macro 'g_warning'
  356 |                                __VA_ARGS__)
      |                                ^~~~~~~~~~~
/media/build/poky/build/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/createrepo-c/0.21.1-r0/git/src/createrepo_c.c:643:72: note: format string is defined here
  643 |       g_warning("    Sourced from location: \'%s\', build timestamp: %ld%s",
      |                                                                      ~~^
      |                                                                        |
      |                                                                        long int
      |                                                                      %lld
Comment 7 Khem Raj 2023-07-26 19:30:07 UTC
Created attachment 4964 [details]
proposed fix.
Comment 9 Yi Zhao 2023-07-28 04:59:55 UTC
Verified with 4.3 M2 RC2 (poky git rev: 3eff0eb5ea77de20d85a2ffc64652579cbd7755c)