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

crash in %filetrigger in scriptlet #3029

Open
keszybz opened this issue Apr 10, 2024 · 4 comments
Open

crash in %filetrigger in scriptlet #3029

keszybz opened this issue Apr 10, 2024 · 4 comments
Labels

Comments

@keszybz
Copy link
Contributor

keszybz commented Apr 10, 2024

I'm trying to add a scriptlet to filesystem.rpm, and rpm fails like this:

$ sudo rpm --root=/var/tmp/inst3 --reinstall x86_64/filesystem-3.18-8.fc41.x86_64.rpm
...
filetriggerin
table: 0x55b04c8b4590
will return
PANIC: unprotected error in call to Lua API (attempt to index a number value)
[1]    887545 IOT instruction  sudo rpm --root=/var/tmp/inst3 --reinstall 

The scriptlet:

%filetriggerin -p <lua> -- /usr/bin
print('filetriggerin')
 
st = posix.stat("/sbin")
 
print(st)
 
if st.type == "link" then
  print('will return')
  return 0
end

print('filetriggerin-YES')

With gdb:

$ sudo gdb --args rpm --root=/var/tmp/inst3 --reinstall x86_64/filesystem-3.18-8.fc41.x86_64.rpm
...
(gdb) r
Starting program: /usr/bin/rpm --root=/var/tmp/inst3 --reinstall x86_64/filesystem-3.18-8.fc41.x86_64.rpm
...
filetriggerin
table: 0x5555556a8510
will return
PANIC: unprotected error in call to Lua API (attempt to index a number value)

Program received signal SIGABRT, Aborted.
0x00007ffff7d82144 in __pthread_kill_implementation () from /lib64/libc.so.6
Missing separate debuginfos, use: dnf debuginfo-install bzip2-libs-1.0.8-18.fc40.x86_64 glibc-2.39-6.fc40.x86_64 libacl-2.3.2-1.fc40.x86_64 libattr-2.5.2-3.fc40.x86_64 libgcc-14.0.1-0.13.fc40.x86_64 libselinux-3.6-4.fc40.x86_64 libzstd-1.5.6-1.fc40.x86_64 lua-libs-5.4.6-5.fc40.x86_64 openssl-libs-3.2.1-2.fc40.x86_64 popt-1.19-6.fc40.x86_64 rpm-sequoia-1.6.0-2.fc40.x86_64 sqlite-libs-3.45.1-2.fc40.x86_64 xz-libs-5.4.6-3.fc40.x86_64 zlib-ng-compat-2.1.6-2.fc40.x86_64
(gdb) bt
#0  0x00007ffff7d82144 in __pthread_kill_implementation () from /lib64/libc.so.6
#1  0x00007ffff7d2a65e in raise () from /lib64/libc.so.6
#2  0x00007ffff7d12902 in abort () from /lib64/libc.so.6
#3  0x00007ffff7b34b7a in luaD_throw.cold () from /lib64/liblua-5.4.so
#4  0x00007ffff7b3d833 in luaG_errormsg () from /lib64/liblua-5.4.so
#5  0x00007ffff7b3cb3d in luaG_runerror () from /lib64/liblua-5.4.so
#6  0x00007ffff7b3d7d5 in luaG_typeerror () from /lib64/liblua-5.4.so
#7  0x00007ffff7b5e9ff in luaV_finishset () from /lib64/liblua-5.4.so
#8  0x00007ffff7b34dff in auxsetstr () from /lib64/liblua-5.4.so
#9  0x00007ffff7f6277f in runLuaScript (plugins=0x555555625170, lvl=<optimized out>, scriptFd=<optimized out>, prefixes=0x0, 
    sname=<optimized out>, argvp=0x7fffffffd8e0, script=0x55555562e750 "NY6", arg1=<optimized out>, arg2=-1, nextFileFunc=<optimized out>)
    at /usr/src/debug/rpm-4.19.1.1-2.fc41.x86_64/lib/rpmscript.c:206
#10 rpmScriptRun (script=<optimized out>, arg1=<optimized out>, arg2=-1, scriptFd=<optimized out>, prefixes=0x0, plugins=0x555555625170)
    at /usr/src/debug/rpm-4.19.1.1-2.fc41.x86_64/lib/rpmscript.c:488
#11 runScript (ts=0x55555559da60, te=0x555555908350, h=<optimized out>, prefixes=0x0, script=<optimized out>, arg1=<optimized out>, arg2=-1)
    at /usr/src/debug/rpm-4.19.1.1-2.fc41.x86_64/lib/transaction.c:1717
#12 0x00007ffff7f7036e in runHandleTriggersInPkg (ts=ts@entry=0x55555559da60, te=te@entry=0x5555555fc390, h=h@entry=0x5555555d3770, 
    sense=sense@entry=65536, tm=<optimized out>, searchMode=<optimized out>, ti=0)
    at /usr/src/debug/rpm-4.19.1.1-2.fc41.x86_64/lib/rpmtriggers.c:436
#13 0x00007ffff7f7083e in runFileTriggers (ts=0x55555559da60, te=0x5555555fc390, sense=65536, tm=2, priorityClass=1)
    at /usr/src/debug/rpm-4.19.1.1-2.fc41.x86_64/lib/rpmtriggers.c:571
#14 0x00007ffff7f504e6 in rpmPackageInstall (ts=<optimized out>, psm=0x5555557f2f60) at /usr/src/debug/rpm-4.19.1.1-2.fc41.x86_64/lib/psm.c:886
#15 runGoal (psm=0x5555557f2f60, goal=<optimized out>) at /usr/src/debug/rpm-4.19.1.1-2.fc41.x86_64/lib/psm.c:1068
#16 rpmpsmRun (ts=0x55555559da60, te=0x5555555fc390, goal=<optimized out>) at /usr/src/debug/rpm-4.19.1.1-2.fc41.x86_64/lib/psm.c:1114
#17 0x00007ffff7f5fc9d in rpmpsmRun (ts=0x55555559da60, te=0x5555555fc390, goal=PKG_INSTALL)
    at /usr/src/debug/rpm-4.19.1.1-2.fc41.x86_64/lib/rpmte.c:594
#18 rpmteProcess (te=te@entry=0x5555555fc390, goal=PKG_INSTALL, num=num@entry=0) at /usr/src/debug/rpm-4.19.1.1-2.fc41.x86_64/lib/rpmte.c:820
#19 0x00007ffff7f6558b in rpmtsProcess (ts=0x55555559da60) at /usr/src/debug/rpm-4.19.1.1-2.fc41.x86_64/lib/transaction.c:1637
#20 rpmtsRun (ts=<optimized out>, okProbs=<optimized out>, ignoreSet=<optimized out>)
    at /usr/src/debug/rpm-4.19.1.1-2.fc41.x86_64/lib/transaction.c:1859
#21 0x00007ffff7f58e94 in rpmcliTransaction (ts=ts@entry=0x55555559da60, ia=ia@entry=0x555555559200 <rpmIArgs>)
    at /usr/src/debug/rpm-4.19.1.1-2.fc41.x86_64/lib/rpminstall.c:300
#22 0x00007ffff7f5a630 in rpmInstall (ts=ts@entry=0x55555559da60, ia=0x555555559200 <rpmIArgs>, fileArgv=<optimized out>)
    at /usr/src/debug/rpm-4.19.1.1-2.fc41.x86_64/lib/rpminstall.c:653
#23 0x0000555555556b87 in main (argc=4, argv=<optimized out>) at /usr/src/debug/rpm-4.19.1.1-2.fc41.x86_64/tools/rpm.c:268

rpm-4.19.1.1-2.fc41.x86_64

For a reproducer, see https://src.fedoraproject.org/fork/zbyszek/rpms/filesystem/tree/crash.
Or https://copr.fedorainfracloud.org/coprs/zbyszek/merged-sbin/builds/, all the failed builds have the failure.

@pmatilai pmatilai added the bug label Apr 10, 2024
@pmatilai
Copy link
Member

Easily reproduced. There issue is related to return 0, something doesn't like data being returned from there.

It's a bug we need to fix, but in the meanwhile, just drop the 0 from the return and it should work.

@pmatilai
Copy link
Member

Oh and, thanks for the report and reproducer!

@pmatilai
Copy link
Member

pmatilai commented Apr 10, 2024

Basically the returned value throws off our expectations wrt the Lua stack.
I'll need a sharper head than I have today to figure what exactly to do with it, we probably should allow returning an exit code for success/failure in this way. And in any case we shouldn't crash.

@keszybz
Copy link
Contributor Author

keszybz commented Apr 10, 2024

Thank you for the quick response. I can confirm that when return 0 is removed, things seems to work again.

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

No branches or pull requests

2 participants