Subject: gpg-related crash with custom formatter (BUG: gpg-interface.c:915: invalid trust level requested -1)

From: Rolf Eike Beer <[email-masked]>
Date: Tue, 18 Apr 2023 08:12:03 +0200

I use this one:

[format]
        pretty = %C(yellow)commit %H%C(auto)%d%Creset%nAuthor: %an <%ae> 
%C(yellow)% GK %GS %C(auto)[%GT% G?]%Creset%nDate:   %ad%n%n%w(0,4,4)%s%n%w(0,
4,4)%+b

When I now run "git log" in a repository that contains commits signed by 
people not in my keyring (e.g. the Gentoo git) I get this backtrace:

BUG: gpg-interface.c:915: invalid trust level requested -1

Program received signal SIGABRT, Aborted.
0x00007ffff7d69d7c in __pthread_kill_implementation () from /lib64/libc.so.6
Missing separate debuginfos, use: zypper install libpcre2-8-0-
debuginfo-10.42-3.6.x86_64 libz1-x86-64-v3-debuginfo-1.2.13-3.4.x86_64
(gdb) bt
#0  0x00007ffff7d69d7c in __pthread_kill_implementation () from /lib64/libc.so.6
#1  0x00007ffff7d18356 in raise () from /lib64/libc.so.6
#2  0x00007ffff7d00897 in abort () from /lib64/libc.so.6
#3  0x00005555558041fe in BUG_vfl (params=0x7fffffffb9e0, fmt=0x555555895608 
"invalid trust level requested %d", line=<optimized out>, file=<optimized out>) 
at /usr/src/debug/git-2.40.0/usage.c:313
#4  BUG_fl (file=<optimized out>, line=<optimized out>, fmt=0x555555895608 
"invalid trust level requested %d") at /usr/src/debug/git-2.40.0/usage.c:330
#5  0x000055555576a816 in gpg_trust_level_to_str (level=<optimized out>) at /
usr/src/debug/git-2.40.0/gpg-interface.c:915
#6  format_commit_one (sb=0x7fffffffbf40, placeholder=0x555555936b65 "GT% G?]
%Creset%nDate:   %ad%n%n%w(0,4,4)%s%n%w(0,4,4)%+b", context=0x7fffffffbde0) at /
usr/src/debug/git-2.40.0/pretty.c:1617
#7  0x000055555576ab1e in format_commit_item (sb=0x7fffffffbf40, 
placeholder=0x555555936b65 "GT% G?]%Creset%nDate:   %ad%n%n%w(0,4,4)%s%n%w(0,
4,4)%+b", context=0x7fffffffbde0) at /usr/src/debug/git-2.40.0/pretty.c:1844
#8  0x00005555557cfc44 in strbuf_expand (sb=0x7fffffffbf40, format=0x555555936b65 
"GT% G?]%Creset%nDate:   %ad%n%n%w(0,4,4)%s%n%w(0,4,4)%+b", fn=0x55555576a8d0 
<format_commit_item>, context=0x7fffffffbde0) at /usr/src/debug/git-2.40.0/
strbuf.c:429
#9  0x000055555576af0e in repo_format_commit_message (r=0x555555928540 
<the_repo>, commit=0x55555594e2d0, format=<optimized out>, sb=0x7fffffffbf40, 
pretty_ctx=<optimized out>) at /usr/src/debug/git-2.40.0/pretty.c:1910
#10 0x000055555571ad10 in show_log (opt=opt@entry=0x7fffffffc570) at /usr/src/
debug/git-2.40.0/log-tree.c:781
#11 0x000055555571bd17 in log_tree_commit (opt=0x7fffffffc570, commit=<optimized 
out>) at /usr/src/debug/git-2.40.0/log-tree.c:1117
#12 0x00005555555e9638 in cmd_log_walk_no_free (rev=0x7fffffffc570) at builtin/
log.c:508
#13 0x00005555555e9d5a in cmd_log_walk (rev=0x7fffffffc570) at builtin/log.c:549
#14 cmd_log (argc=1, argv=0x7fffffffd7c0, prefix=0x0) at builtin/log.c:883
#15 0x00005555555782bb in run_builtin (argv=0x7fffffffd7c0, argc=1, 
p=0x5555558fa000 <commands.lto_priv+1440>) at /usr/src/debug/git-2.40.0/git.c:
445
#16 handle_builtin (argc=1, argv=0x7fffffffd7c0) at /usr/src/debug/git-2.40.0/
git.c:699
#17 0x00005555555787e7 in run_argv (argcp=0x7fffffffd50c, argv=0x7fffffffd530) at /
usr/src/debug/git-2.40.0/git.c:763
#18 0x000055555557464b in cmd_main (argv=<optimized out>, argc=<optimized 
out>) at /usr/src/debug/git-2.40.0/git.c:898
#19 main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/
git-2.40.0/common-main.c:57

This is not absolutely new, it is broken for a while but I was too lazy to 
report (sorry about that). It has worked in the past, i.e. when I created that 
formatter (IIRC at least 2 years ago).

System is an openSUSE Tumbleweed installation on amd64.

Greetings,

Eike
-- 
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source