Bug 245767 - ports-mgmt/pkg: 1.14.2 critical SQLITE error is ignored
Summary: ports-mgmt/pkg: 1.14.2 critical SQLITE error is ignored
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-pkg (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-20 15:44 UTC by Maxim Sobolev
Modified: 2020-06-16 11:37 UTC (History)
2 users (show)

See Also:


Attachments
Patch to fix the issue. (415 bytes, patch)
2020-04-20 15:44 UTC, Maxim Sobolev
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maxim Sobolev freebsd_committer freebsd_triage 2020-04-20 15:44:29 UTC
Created attachment 213606 [details]
Patch to fix the issue.

One of our build envs has run out of disk space, and we've noticed that error is not raised by the pkg failure, resulting in quite a mess.

[2020-04-18T04:49:42.516Z] + rm /tmp/rrd_create.sh /tmp/rrd.conf
[2020-04-18T04:49:42.516Z] + rm -f /tmp/sh.qPrEwG
[2020-04-18T04:49:42.770Z] pkg-static: sqlite error while executing COMMIT TRANSACTION
  in file pkgdb.c:1292: database or disk is full
[2020-04-18T04:49:43.046Z] ===>  Building package for ssp-5.3.20190821165853_3
[2020-04-18T04:50:30.208Z] ===>  Cleaning for ssp-5.3.20190821165853_3

Further investigation shows the following call stack:

#0  0x000000000046f66f in run_transaction (sqlite=0x8017fc008, query=0x8ebb87 "COMMIT TRANSACTION", savepoint=0x0) at pkgdb.c:1298
#1  0x000000000046f732 in pkgdb_transaction_commit_sqlite (sqlite=0x8017fc008, savepoint=0x0) at pkgdb.c:1320
#2  0x000000000047200c in pkgdb_register_finale (db=0x8010a66e0, retcode=0, savepoint=0x0) at pkgdb.c:2383
#3  0x0000000000469d45 in pkg_add_port (db=0x8010a66e0, pkg=0x801079000, input_path=0x7fffffffe7ef "/tmp/media/ssp_port/work/stage", reloc=0x0, testing=false) at pkg_ports.c:1365
#4  0x00000000004167e6 in exec_register (argc=7, argv=0x7fffffffe428) at register.c:195
#5  0x000000000041145c in main (argc=7, argv=0x7fffffffe428) at main.c:886

The culprit seems in the pkg_add_port(), the return value of pkgdb_register_finale() is not checked, resulting in error condition being essentially lost.

(gdb) up
#3  0x0000000000469d45 in pkg_add_port (db=0x8010a66e0, pkg=0x801079000, input_path=0x7fffffffe7ef "/tmp/media/ssp_port/work/stage", reloc=0x0, testing=false) at pkg_ports.c:1365
1365            pkgdb_register_finale(db, rc, NULL);
(gdb) l
1360                            utstring_free(message);
1361                    }
1362            }
1363
1364    cleanup:
1365            pkgdb_register_finale(db, rc, NULL);
1366
1367            return (rc);
1368    }
(gdb) print rc
$2 = 0