{"action":"created","issue":{"url":"https://api.github.com/repos/rpm-software-management/rpm/issues/92","repository_url":"https://api.github.com/repos/rpm-software-management/rpm","labels_url":"https://api.github.com/repos/rpm-software-management/rpm/issues/92/labels{/name}","comments_url":"https://api.github.com/repos/rpm-software-management/rpm/issues/92/comments","events_url":"https://api.github.com/repos/rpm-software-management/rpm/issues/92/events","html_url":"https://github.com/rpm-software-management/rpm/pull/92","id":177833063,"number":92,"title":"Couple fixes in rpmdb (double free, and rpmdbCheckTerminate return code)","user":{"login":"glebfm","id":1343999,"avatar_url":"https://avatars.githubusercontent.com/u/1343999?v=3","gravatar_id":"","url":"https://api.github.com/users/glebfm","html_url":"https://github.com/glebfm","followers_url":"https://api.github.com/users/glebfm/followers","following_url":"https://api.github.com/users/glebfm/following{/other_user}","gists_url":"https://api.github.com/users/glebfm/gists{/gist_id}","starred_url":"https://api.github.com/users/glebfm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glebfm/subscriptions","organizations_url":"https://api.github.com/users/glebfm/orgs","repos_url":"https://api.github.com/users/glebfm/repos","events_url":"https://api.github.com/users/glebfm/events{/privacy}","received_events_url":"https://api.github.com/users/glebfm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-19T16:33:53Z","updated_at":"2016-09-21T08:10:03Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rpm-software-management/rpm/pulls/92","html_url":"https://github.com/rpm-software-management/rpm/pull/92","diff_url":"https://github.com/rpm-software-management/rpm/pull/92.diff","patch_url":"https://github.com/rpm-software-management/rpm/pull/92.patch"},"body":"This code:\r\n```c\r\n#include <rpm/rpmdb.h>\r\n#include <rpm/rpmts.h>\r\n#include <rpm/rpmlib.h>\r\n#include <signal.h>\r\n\r\nclass A {\r\n    private:\r\n        rpmts ts;\r\n        rpmdbMatchIterator mi;\r\n    public:\r\n        A() {\r\n            rpmReadConfigFiles(NULL, NULL);\r\n            ts = rpmtsCreate();\r\n            mi = rpmtsInitIterator(ts, RPMDBI_PACKAGES, NULL, 0);\r\n        };\r\n        ~A() {\r\n            rpmdbFreeIterator(mi);\r\n            rpmtsFree(ts);\r\n        };\r\n};\r\n\r\nA a;\r\n\r\nint main() {\r\n    raise(SIGTERM);\r\n    rpmdbCheckSignals();\r\n    return 0;\r\n}\r\n```\r\ntries to free `MatchIterator` again in `atexit` destructor.\r\n\r\n```\r\nProgram received signal SIGSEGV, Segmentation fault.\r\n#0  0x00007ffff7b57c17 in ?? () from /usr/lib64/librpm.so.7\r\n#1  0x00007ffff7b5fbaa in rpmdbFreeIterator () from /usr/lib64/librpm.so.7\r\n#2  0x00000000004009b6 in A::~A (this=0x601080 <a>, __in_chrg=<optimized out>) at t.cc:17\r\n#3  0x00007ffff77d1ca8 in __run_exit_handlers (status=1, listp=0x7ffff7b395d8 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:82\r\n#4  0x00007ffff77d1cf5 in __GI_exit (status=<optimized out>) at exit.c:104\r\n#5  0x00007ffff7b5f513 in rpmdbCheckSignals () from /usr/lib64/librpm.so.7\r\n#6  0x00000000004008e9 in main () at t.cc:26\r\n```\r\n\r\nI tried `if (rpmdbCheckTerminate(0) == 0) rpmdbFreeIterator(mi);`, but `rpmdbCheckTerminate` return code is not reliable."},"comment":{"url":"https://api.github.com/repos/rpm-software-management/rpm/issues/comments/248541460","html_url":"https://github.com/rpm-software-management/rpm/pull/92#issuecomment-248541460","issue_url":"https://api.github.com/repos/rpm-software-management/rpm/issues/92","id":248541460,"user":{"login":"rpm-maint","id":14089427,"avatar_url":"https://avatars.githubusercontent.com/u/14089427?v=3","gravatar_id":"","url":"https://api.github.com/users/rpm-maint","html_url":"https://github.com/rpm-maint","followers_url":"https://api.github.com/users/rpm-maint/followers","following_url":"https://api.github.com/users/rpm-maint/following{/other_user}","gists_url":"https://api.github.com/users/rpm-maint/gists{/gist_id}","starred_url":"https://api.github.com/users/rpm-maint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rpm-maint/subscriptions","organizations_url":"https://api.github.com/users/rpm-maint/orgs","repos_url":"https://api.github.com/users/rpm-maint/repos","events_url":"https://api.github.com/users/rpm-maint/events{/privacy}","received_events_url":"https://api.github.com/users/rpm-maint/received_events","type":"User","site_admin":false},"created_at":"2016-09-21T08:10:03Z","updated_at":"2016-09-21T08:10:03Z","body":"On 09/19/2016 07:33 PM, Gleb Pfotenhauer-Malinowski wrote:\n> This code:\n> ```\n> #include <rpm/rpmdb.h>\n> #include <rpm/rpmts.h>\n> #include <rpm/rpmlib.h>\n> #include <signal.h>\n>\n> class A {\n>     private:\n>         rpmts ts;\n>         rpmdbMatchIterator mi;\n>     public:\n>         A() {\n>             rpmReadConfigFiles(NULL, NULL);\n>             ts = rpmtsCreate();\n>             mi = rpmtsInitIterator(ts, RPMDBI_PACKAGES, NULL, 0);\n>         };\n>         ~A() {\n>             rpmdbFreeIterator(mi);\n>             rpmtsFree(ts);\n>         };\n> };\n>\n> A a;\n>\n> int main() {\n>     raise(SIGTERM);\n>     rpmdbCheckSignals();\n>     return 0;\n> }\n> ```\n> tries to free `MatchIterator` again in `atexit` destructor.\n>\n> Program received signal SIGSEGV, Segmentation fault.\n> #0  0x00007ffff7b57c17 in ?? () from /usr/lib64/librpm.so.7\n> #1  0x00007ffff7b5fbaa in rpmdbFreeIterator () from /usr/lib64/librpm.so.7\n> #2  0x00000000004009b6 in A::~A (this=0x601080 <a>, __in_chrg=<optimized out>) at t.cc:17\n> #3  0x00007ffff77d1ca8 in __run_exit_handlers (status=1, listp=0x7ffff7b395d8 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:82\n> #4  0x00007ffff77d1cf5 in __GI_exit (status=<optimized out>) at exit.c:104\n> #5  0x00007ffff7b5f513 in rpmdbCheckSignals () from /usr/lib64/librpm.so.7\n> #6  0x00000000004008e9 in main () at t.cc:26\n>\n> I tried `if (rpmdbCheckTerminate(0) == 0) rpmdbFreeIterator(mi);`, but `rpmdbCheckTerminate` return code is not reliable.\n> You can view, comment on, or merge this pull request online at:\n>\n>   https://github.com/rpm-software-management/rpm/pull/92\n>\n> -- Commit Summary --\n>\n>   * rpmdb.c: avoid double free in rpmdbClose, rpmdbMatchIterator, ...\n>   * rpmdb.c: (rpmdbCheckTerminate) return non-zero on subsequent runs\n>\n> -- File Changes --\n>\n>     M lib/rpmdb.c (17)\n>\n> -- Patch Links --\n>\n> https://github.com/rpm-software-management/rpm/pull/92.patch\n> https://github.com/rpm-software-management/rpm/pull/92.diff\n\nWow, that sounds like a fix for this rather ancient issue that I guess \nnobody ever properly investigated:\nhttps://www.redhat.com/archives/rpm-list/2002-November/msg00230.html\n\n\t- Panu -\n"}}
{"actor":{"display_login":"rpm-maint"}}