{"action":"created","comment":{"url":"https://api.github.com/repos/Z3Prover/z3/pulls/comments/75554153","id":75554153,"diff_hunk":"@@ -123,48 +123,80 @@ namespace sat {\n \n     clause_allocator::clause_allocator():\n         m_allocator(\"clause-allocator\") {\n-#ifdef _AMD64_\n+#if defined(_AMD64_) \n         m_num_segments = 0;\n+#if defined(Z3DEBUG)\n+        m_overflow_valid = false;\n+#endif\n #endif\n     }\n \n     clause * clause_allocator::get_clause(clause_offset cls_off) const {\n-#ifdef _AMD64_\n+#if defined(_AMD64_) \n+#if defined (Z3DEBUG)\n+        clause const* result;\n+        if (m_overflow_valid && m_cls_offset2ptr.find(cls_off, result)) {\n+            return const_cast<clause*>(result);\n+        }\n+#endif\n         return reinterpret_cast<clause *>(m_segments[cls_off & c_aligment_mask] + (static_cast<size_t>(cls_off) & ~c_aligment_mask));\n #else\n         return reinterpret_cast<clause *>(cls_off);\n #endif\n     }\n \n-#ifdef _AMD64_\n-    unsigned clause_allocator::get_segment(size_t ptr) {\n+#if defined(_AMD64_) \n+    unsigned clause_allocator::get_segment(clause const* cls) {\n+        size_t ptr = reinterpret_cast<size_t>(cls);\n+\n         SASSERT((ptr & c_aligment_mask) == 0);\n         ptr &= ~0xFFFFFFFFull; // Keep only high part\n         unsigned i = 0;\n         for (i = 0; i < m_num_segments; ++i)\n             if (m_segments[i] == ptr)\n                 return i;\n         i = m_num_segments;\n-        m_num_segments++;\n-        SASSERT(m_num_segments <= c_max_segments);\n-        if (i >= c_max_segments)\n+#if defined(Z3DEBUG)\n+        SASSERT(i < c_max_segments);\n+        if (i + 1 == c_max_segments) {\n+            m_overflow_valid = true;\n+            i += c_max_segments * m_cls_offset2ptr.size();\n+            m_ptr2cls_offset.insert(ptr, i);","path":"src/sat/sat_clause.cpp","position":49,"original_position":49,"commit_id":"5069da62a3a2338e0f13e6fde82c9a985e3082a5","original_commit_id":"5069da62a3a2338e0f13e6fde82c9a985e3082a5","user":{"login":"izbyshev","id":11427362,"avatar_url":"https://avatars.githubusercontent.com/u/11427362?v=3","gravatar_id":"","url":"https://api.github.com/users/izbyshev","html_url":"https://github.com/izbyshev","followers_url":"https://api.github.com/users/izbyshev/followers","following_url":"https://api.github.com/users/izbyshev/following{/other_user}","gists_url":"https://api.github.com/users/izbyshev/gists{/gist_id}","starred_url":"https://api.github.com/users/izbyshev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/izbyshev/subscriptions","organizations_url":"https://api.github.com/users/izbyshev/orgs","repos_url":"https://api.github.com/users/izbyshev/repos","events_url":"https://api.github.com/users/izbyshev/events{/privacy}","received_events_url":"https://api.github.com/users/izbyshev/received_events","type":"User","site_admin":false},"body":"Also, what is the reason of having `m_ptr2cls_offset` at all if, after we run out of normal segments, each time `clause_allocator::get_segment()` is called a new index is created at line 163 and the only lookup in `clause_allocator::get_offset()` seems to be unnecessary?","created_at":"2016-08-19T21:29:03Z","updated_at":"2016-08-19T21:29:03Z","html_url":"https://github.com/Z3Prover/z3/pull/715#discussion_r75554153","pull_request_url":"https://api.github.com/repos/Z3Prover/z3/pulls/715","_links":{"self":{"href":"https://api.github.com/repos/Z3Prover/z3/pulls/comments/75554153"},"html":{"href":"https://github.com/Z3Prover/z3/pull/715#discussion_r75554153"},"pull_request":{"href":"https://api.github.com/repos/Z3Prover/z3/pulls/715"}}},"pull_request":{"url":"https://api.github.com/repos/Z3Prover/z3/pulls/715","id":82003405,"html_url":"https://github.com/Z3Prover/z3/pull/715","diff_url":"https://github.com/Z3Prover/z3/pull/715.diff","patch_url":"https://github.com/Z3Prover/z3/pull/715.patch","issue_url":"https://api.github.com/repos/Z3Prover/z3/issues/715","number":715,"state":"open","locked":false,"title":"Make clause offset conversion safe for debug mode AMD64.","user":{"login":"NikolajBjorner","id":3085284,"avatar_url":"https://avatars.githubusercontent.com/u/3085284?v=3","gravatar_id":"","url":"https://api.github.com/users/NikolajBjorner","html_url":"https://github.com/NikolajBjorner","followers_url":"https://api.github.com/users/NikolajBjorner/followers","following_url":"https://api.github.com/users/NikolajBjorner/following{/other_user}","gists_url":"https://api.github.com/users/NikolajBjorner/gists{/gist_id}","starred_url":"https://api.github.com/users/NikolajBjorner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NikolajBjorner/subscriptions","organizations_url":"https://api.github.com/users/NikolajBjorner/orgs","repos_url":"https://api.github.com/users/NikolajBjorner/repos","events_url":"https://api.github.com/users/NikolajBjorner/events{/privacy}","received_events_url":"https://api.github.com/users/NikolajBjorner/received_events","type":"User","site_admin":false},"body":"The following is a proposed change to address problems running with 64bit systems whose allocators use random high-order bits of the virtual address space. The compression of 64 bit address spaces into 32 bits (available in clause_offset type), relies on an assumption that addresses are allocated within a limited range of high-order bits. Address sanitizer systems will not follow this pattern as reported in #436. Furthermore, issue #712, reports the same problem, also under debug mode. \r\nOn non-debug mode, the small object allocator uses chunks, so more clauses are required to fall back to an allocator that potentially uses different high-order virtual address ranges. In non-debug mode, the code now throws instead of falling back to hash-tables. ","created_at":"2016-08-19T15:52:16Z","updated_at":"2016-08-19T21:29:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ab84b2b6d309e1dd7b6231f90981b5ada2e73a32","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Z3Prover/z3/pulls/715/commits","review_comments_url":"https://api.github.com/repos/Z3Prover/z3/pulls/715/comments","review_comment_url":"https://api.github.com/repos/Z3Prover/z3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Z3Prover/z3/issues/715/comments","statuses_url":"https://api.github.com/repos/Z3Prover/z3/statuses/5069da62a3a2338e0f13e6fde82c9a985e3082a5","head":{"label":"NikolajBjorner:master","ref":"master","sha":"5069da62a3a2338e0f13e6fde82c9a985e3082a5","user":{"login":"NikolajBjorner","id":3085284,"avatar_url":"https://avatars.githubusercontent.com/u/3085284?v=3","gravatar_id":"","url":"https://api.github.com/users/NikolajBjorner","html_url":"https://github.com/NikolajBjorner","followers_url":"https://api.github.com/users/NikolajBjorner/followers","following_url":"https://api.github.com/users/NikolajBjorner/following{/other_user}","gists_url":"https://api.github.com/users/NikolajBjorner/gists{/gist_id}","starred_url":"https://api.github.com/users/NikolajBjorner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NikolajBjorner/subscriptions","organizations_url":"https://api.github.com/users/NikolajBjorner/orgs","repos_url":"https://api.github.com/users/NikolajBjorner/repos","events_url":"https://api.github.com/users/NikolajBjorner/events{/privacy}","received_events_url":"https://api.github.com/users/NikolajBjorner/received_events","type":"User","site_admin":false},"repo":{"id":35638642,"name":"z3","full_name":"NikolajBjorner/z3","owner":{"login":"NikolajBjorner","id":3085284,"avatar_url":"https://avatars.githubusercontent.com/u/3085284?v=3","gravatar_id":"","url":"https://api.github.com/users/NikolajBjorner","html_url":"https://github.com/NikolajBjorner","followers_url":"https://api.github.com/users/NikolajBjorner/followers","following_url":"https://api.github.com/users/NikolajBjorner/following{/other_user}","gists_url":"https://api.github.com/users/NikolajBjorner/gists{/gist_id}","starred_url":"https://api.github.com/users/NikolajBjorner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NikolajBjorner/subscriptions","organizations_url":"https://api.github.com/users/NikolajBjorner/orgs","repos_url":"https://api.github.com/users/NikolajBjorner/repos","events_url":"https://api.github.com/users/NikolajBjorner/events{/privacy}","received_events_url":"https://api.github.com/users/NikolajBjorner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/NikolajBjorner/z3","description":"The Z3 Theorem Prover","fork":true,"url":"https://api.github.com/repos/NikolajBjorner/z3","forks_url":"https://api.github.com/repos/NikolajBjorner/z3/forks","keys_url":"https://api.github.com/repos/NikolajBjorner/z3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NikolajBjorner/z3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NikolajBjorner/z3/teams","hooks_url":"https://api.github.com/repos/NikolajBjorner/z3/hooks","issue_events_url":"https://api.github.com/repos/NikolajBjorner/z3/issues/events{/number}","events_url":"https://api.github.com/repos/NikolajBjorner/z3/events","assignees_url":"https://api.github.com/repos/NikolajBjorner/z3/assignees{/user}","branches_url":"https://api.github.com/repos/NikolajBjorner/z3/branches{/branch}","tags_url":"https://api.github.com/repos/NikolajBjorner/z3/tags","blobs_url":"https://api.github.com/repos/NikolajBjorner/z3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NikolajBjorner/z3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NikolajBjorner/z3/git/refs{/sha}","trees_url":"https://api.github.com/repos/NikolajBjorner/z3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NikolajBjorner/z3/statuses/{sha}","languages_url":"https://api.github.com/repos/NikolajBjorner/z3/languages","stargazers_url":"https://api.github.com/repos/NikolajBjorner/z3/stargazers","contributors_url":"https://api.github.com/repos/NikolajBjorner/z3/contributors","subscribers_url":"https://api.github.com/repos/NikolajBjorner/z3/subscribers","subscription_url":"https://api.github.com/repos/NikolajBjorner/z3/subscription","commits_url":"https://api.github.com/repos/NikolajBjorner/z3/commits{/sha}","git_commits_url":"https://api.github.com/repos/NikolajBjorner/z3/git/commits{/sha}","comments_url":"https://api.github.com/repos/NikolajBjorner/z3/comments{/number}","issue_comment_url":"https://api.github.com/repos/NikolajBjorner/z3/issues/comments{/number}","contents_url":"https://api.github.com/repos/NikolajBjorner/z3/contents/{+path}","compare_url":"https://api.github.com/repos/NikolajBjorner/z3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NikolajBjorner/z3/merges","archive_url":"https://api.github.com/repos/NikolajBjorner/z3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NikolajBjorner/z3/downloads","issues_url":"https://api.github.com/repos/NikolajBjorner/z3/issues{/number}","pulls_url":"https://api.github.com/repos/NikolajBjorner/z3/pulls{/number}","milestones_url":"https://api.github.com/repos/NikolajBjorner/z3/milestones{/number}","notifications_url":"https://api.github.com/repos/NikolajBjorner/z3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NikolajBjorner/z3/labels{/name}","releases_url":"https://api.github.com/repos/NikolajBjorner/z3/releases{/id}","deployments_url":"https://api.github.com/repos/NikolajBjorner/z3/deployments","created_at":"2015-05-14T21:45:35Z","updated_at":"2016-01-11T03:17:07Z","pushed_at":"2016-08-19T15:45:13Z","git_url":"git://github.com/NikolajBjorner/z3.git","ssh_url":"git@github.com:NikolajBjorner/z3.git","clone_url":"https://github.com/NikolajBjorner/z3.git","svn_url":"https://github.com/NikolajBjorner/z3","homepage":null,"size":18235,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Z3Prover:master","ref":"master","sha":"e8141aaa84bb47a927282ce0318686fd12c7b2f9","user":{"login":"Z3Prover","id":11668813,"avatar_url":"https://avatars.githubusercontent.com/u/11668813?v=3","gravatar_id":"","url":"https://api.github.com/users/Z3Prover","html_url":"https://github.com/Z3Prover","followers_url":"https://api.github.com/users/Z3Prover/followers","following_url":"https://api.github.com/users/Z3Prover/following{/other_user}","gists_url":"https://api.github.com/users/Z3Prover/gists{/gist_id}","starred_url":"https://api.github.com/users/Z3Prover/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Z3Prover/subscriptions","organizations_url":"https://api.github.com/users/Z3Prover/orgs","repos_url":"https://api.github.com/users/Z3Prover/repos","events_url":"https://api.github.com/users/Z3Prover/events{/privacy}","received_events_url":"https://api.github.com/users/Z3Prover/received_events","type":"Organization","site_admin":false},"repo":{"id":32944298,"name":"z3","full_name":"Z3Prover/z3","owner":{"login":"Z3Prover","id":11668813,"avatar_url":"https://avatars.githubusercontent.com/u/11668813?v=3","gravatar_id":"","url":"https://api.github.com/users/Z3Prover","html_url":"https://github.com/Z3Prover","followers_url":"https://api.github.com/users/Z3Prover/followers","following_url":"https://api.github.com/users/Z3Prover/following{/other_user}","gists_url":"https://api.github.com/users/Z3Prover/gists{/gist_id}","starred_url":"https://api.github.com/users/Z3Prover/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Z3Prover/subscriptions","organizations_url":"https://api.github.com/users/Z3Prover/orgs","repos_url":"https://api.github.com/users/Z3Prover/repos","events_url":"https://api.github.com/users/Z3Prover/events{/privacy}","received_events_url":"https://api.github.com/users/Z3Prover/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Z3Prover/z3","description":"The Z3 Theorem Prover","fork":false,"url":"https://api.github.com/repos/Z3Prover/z3","forks_url":"https://api.github.com/repos/Z3Prover/z3/forks","keys_url":"https://api.github.com/repos/Z3Prover/z3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Z3Prover/z3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Z3Prover/z3/teams","hooks_url":"https://api.github.com/repos/Z3Prover/z3/hooks","issue_events_url":"https://api.github.com/repos/Z3Prover/z3/issues/events{/number}","events_url":"https://api.github.com/repos/Z3Prover/z3/events","assignees_url":"https://api.github.com/repos/Z3Prover/z3/assignees{/user}","branches_url":"https://api.github.com/repos/Z3Prover/z3/branches{/branch}","tags_url":"https://api.github.com/repos/Z3Prover/z3/tags","blobs_url":"https://api.github.com/repos/Z3Prover/z3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Z3Prover/z3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Z3Prover/z3/git/refs{/sha}","trees_url":"https://api.github.com/repos/Z3Prover/z3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Z3Prover/z3/statuses/{sha}","languages_url":"https://api.github.com/repos/Z3Prover/z3/languages","stargazers_url":"https://api.github.com/repos/Z3Prover/z3/stargazers","contributors_url":"https://api.github.com/repos/Z3Prover/z3/contributors","subscribers_url":"https://api.github.com/repos/Z3Prover/z3/subscribers","subscription_url":"https://api.github.com/repos/Z3Prover/z3/subscription","commits_url":"https://api.github.com/repos/Z3Prover/z3/commits{/sha}","git_commits_url":"https://api.github.com/repos/Z3Prover/z3/git/commits{/sha}","comments_url":"https://api.github.com/repos/Z3Prover/z3/comments{/number}","issue_comment_url":"https://api.github.com/repos/Z3Prover/z3/issues/comments{/number}","contents_url":"https://api.github.com/repos/Z3Prover/z3/contents/{+path}","compare_url":"https://api.github.com/repos/Z3Prover/z3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Z3Prover/z3/merges","archive_url":"https://api.github.com/repos/Z3Prover/z3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Z3Prover/z3/downloads","issues_url":"https://api.github.com/repos/Z3Prover/z3/issues{/number}","pulls_url":"https://api.github.com/repos/Z3Prover/z3/pulls{/number}","milestones_url":"https://api.github.com/repos/Z3Prover/z3/milestones{/number}","notifications_url":"https://api.github.com/repos/Z3Prover/z3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Z3Prover/z3/labels{/name}","releases_url":"https://api.github.com/repos/Z3Prover/z3/releases{/id}","deployments_url":"https://api.github.com/repos/Z3Prover/z3/deployments","created_at":"2015-03-26T18:16:07Z","updated_at":"2016-08-19T21:13:08Z","pushed_at":"2016-08-19T15:52:16Z","git_url":"git://github.com/Z3Prover/z3.git","ssh_url":"git@github.com:Z3Prover/z3.git","clone_url":"https://github.com/Z3Prover/z3.git","svn_url":"https://github.com/Z3Prover/z3","homepage":null,"size":24112,"stargazers_count":1693,"watchers_count":1693,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":301,"mirror_url":null,"open_issues_count":54,"forks":301,"open_issues":54,"watchers":1693,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Z3Prover/z3/pulls/715"},"html":{"href":"https://github.com/Z3Prover/z3/pull/715"},"issue":{"href":"https://api.github.com/repos/Z3Prover/z3/issues/715"},"comments":{"href":"https://api.github.com/repos/Z3Prover/z3/issues/715/comments"},"review_comments":{"href":"https://api.github.com/repos/Z3Prover/z3/pulls/715/comments"},"review_comment":{"href":"https://api.github.com/repos/Z3Prover/z3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Z3Prover/z3/pulls/715/commits"},"statuses":{"href":"https://api.github.com/repos/Z3Prover/z3/statuses/5069da62a3a2338e0f13e6fde82c9a985e3082a5"}}}}
{"actor":{"display_login":"izbyshev"}}