Skip to content

Commit 1573470

Browse files
Nikolai Tillmannfacebook-github-bot
Nikolai Tillmann
authored andcommitted
Promote redex-staging to redex-stable, Redex "G" release
Summary: allow-large-files Sync redex-stable with the contents of redex-staging at revision 97bdf48dc1bc. Reviewed By: ssj933 Differential Revision: D65169513 fbshipit-source-id: afe02fbb4fa407f7b4d1459c41728be60fdb242d
1 parent f9d7e62 commit 1573470

File tree

82 files changed

+2973
-782
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2973
-782
lines changed

.circleci/config.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,15 @@ jobs:
489489
# Note: buildpack-deps:testing is the same as stable at time of writing,
490490
# so jump to unstable directly.
491491

492-
build-deb_unstable:
493-
docker:
494-
- image: buildpack-deps:unstable-scm
495-
# GCC is hungry.
496-
resource_class: large
497-
steps:
498-
- build_debian:
499-
job_name: debian_unstable
492+
# TODO T198252082: Re-enable after migrating tests from DX to D8
493+
# build-deb_unstable:
494+
# docker:
495+
# - image: buildpack-deps:unstable-scm
496+
# # GCC is hungry.
497+
# resource_class: large
498+
# steps:
499+
# - build_debian:
500+
# job_name: debian_unstable
500501

501502
build-deb_unstable-w-clang:
502503
docker:
Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: build_debian
1+
name: prepare_debian
22
inputs:
33
save_boost_cache:
44
required: false
@@ -12,32 +12,35 @@ inputs:
1212
mode_32:
1313
required: false
1414
default: false
15-
job_name:
16-
required: false
1715
runs:
1816
using: composite
1917
steps:
18+
- name: Timestamp (1)
19+
run: date
20+
shell: bash
2021
# Reinitialize. It is easier to do this (again) to not have to deal with
2122
# fixing `uses:` paths.
2223
- uses: actions/[email protected]
2324
with:
2425
path: repo
25-
# We want to run restore-mtime, which needs to find actual commit data
26-
# and not just the shallow default result. The easiest way for this seems
27-
# to be the filter support of Github (https://github.blog/open-source/git/get-up-to-speed-with-partial-clone-and-shallow-clone/).
28-
fetch-depth: 1000000
29-
filter: "tree:0"
26+
# We want the whole repo because of restore-mtime. Using filters is
27+
# observably slower.
28+
fetch-depth: 0
29+
- name: Timestamp (2)
30+
run: date
31+
shell: bash
3032
- uses: ./.github/actions/debian-based-image-build-setup
3133
with:
3234
mode_32: "${{ inputs.mode_32 }}"
3335
install_clang: "${{ inputs.install_clang }}"
3436
install_clang_llvm_org: "${{ inputs.install_clang_llvm_org }}"
37+
- name: Timestamp (3)
38+
run: date
39+
shell: bash
3540
- name: Run git-restore-mtime
3641
run: git restore-mtime
3742
working-directory: repo
3843
shell: bash
39-
- uses: ./.github/actions/setup-build-and-test-w-make
40-
with:
41-
save_boost_cache: "${{ inputs.save_boost_cache }}"
42-
mode_32: "${{ inputs.mode_32 }}"
43-
job_name: "${{ inputs.job_name }}-${{ inputs.install_clang_llvm_org }}"
44+
- name: Timestamp (4)
45+
run: date
46+
shell: bash

.github/actions/setup-build-and-test-w-make-impl/action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ runs:
2929
- name: Cache build
3030
uses: actions/[email protected]
3131
with:
32-
key: v1-build-cache-${{ inputs.job_name }}.${{ inputs.setup_toolchain_extra }}.${{ inputs.configure_extra }}-${{ runner.arch }}-${{ github.ref_name }}-${{ github.sha }}
32+
key: v2-build-cache-${{ inputs.job_name }}.${{ inputs.setup_toolchain_extra }}.${{ inputs.configure_extra }}-${{ runner.arch }}-${{ github.ref_name }}-${{ github.sha }}
3333
path: build.tar.zstd
3434
restore-keys: |
35-
v1-build-cache-${{ inputs.job_name }}.${{ inputs.setup_toolchain_extra }}.${{ inputs.configure_extra }}-${{ runner.arch }}-${{ github.ref_name }}
36-
v1-build-cache-${{ inputs.job_name }}.${{ inputs.setup_toolchain_extra }}.${{ inputs.configure_extra }}-${{ runner.arch }}-main
37-
v1-build-cache-${{ inputs.job_name }}.${{ inputs.setup_toolchain_extra }}.${{ inputs.configure_extra }}-${{ runner.arch }}
35+
v2-build-cache-${{ inputs.job_name }}.${{ inputs.setup_toolchain_extra }}.${{ inputs.configure_extra }}-${{ runner.arch }}-${{ github.ref_name }}-
36+
v2-build-cache-${{ inputs.job_name }}.${{ inputs.setup_toolchain_extra }}.${{ inputs.configure_extra }}-${{ runner.arch }}-main-
37+
v2-build-cache-${{ inputs.job_name }}.${{ inputs.setup_toolchain_extra }}.${{ inputs.configure_extra }}-${{ runner.arch }}-
3838
# Would be nice to use the cache action output, but we want to unpack even on
3939
# restore_keys hit.
4040
- name: Unpack build cache

.github/actions/test-build-setup/action.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ runs:
1414
- name: Cache SDK
1515
uses: actions/[email protected]
1616
with:
17-
key: v3-android-build-tools
17+
key: v4-android-build-tools
1818
path: sdk.tar.zstd
19-
restore-keys: v3-android-build-tools
2019
- name: Check/Install (SDK)
2120
run: |-
2221
if [ -e sdk/build-tools/29.0.2/dx ] ; then echo "Found SDK." ; exit 0 ; fi
@@ -41,5 +40,5 @@ runs:
4140
# Compress for cache. For reason see description of build cache.
4241
# We do not need the emulator and it is large. Delete.
4342
rm -rf sdk/emulator 2>/dev/null
44-
tar cf - sdk | zstd -T0 -3 > sdk.tar.zstd
43+
tar cf - sdk | zstd -T0 -9 > sdk.tar.zstd
4544
shell: bash

.github/workflows/build_main.yml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,23 @@ jobs:
1616
runs-on: 4-core-ubuntu-20.04
1717
steps:
1818
- uses: actions/[email protected]
19-
- uses: "./.github/actions/build_debian"
19+
- uses: "./.github/actions/prepare_debian"
20+
- uses: ./.github/actions/setup-build-and-test-w-make
2021
with:
22+
save_boost_cache: false
23+
mode_32: false
2124
job_name: ubuntu_20.04
2225
build-22_04:
2326
runs-on: 4-core-ubuntu
2427
steps:
2528
- uses: actions/[email protected]
26-
- uses: "./.github/actions/build_debian"
29+
- uses: "./.github/actions/prepare_debian"
30+
- uses: ./.github/actions/setup-build-and-test-w-make
2731
with:
32+
save_boost_cache: false
33+
mode_32: false
2834
job_name: ubuntu_22.04
35+
2936
# No supported Github runners:
3037
# * debian 10
3138
# * debian 12
@@ -39,6 +46,12 @@ jobs:
3946
# with:
4047
# mode_32: true
4148
# job_name: debian_12_32
49+
#
50+
# For new-style config we'd need:
51+
# setup_toolchain_extra: '32'
52+
# configure_extra: "--host=i686-linux-gnu CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32"
53+
#
54+
#
4255
build-deb_stable-w-clang-llvm-org:
4356
runs-on: 4-core-ubuntu
4457
env:
@@ -52,10 +65,15 @@ jobs:
5265
- 17
5366
steps:
5467
- uses: actions/[email protected]
55-
- uses: "./.github/actions/build_debian"
68+
- uses: "./.github/actions/prepare_debian"
5669
with:
5770
install_clang_llvm_org: "${{ matrix.clang_version }}"
58-
job_name: ubuntu_22_clang_upstream
71+
- uses: ./.github/actions/setup-build-and-test-w-make
72+
with:
73+
save_boost_cache: false
74+
mode_32: false
75+
job_name: "ubuntu_22_clang_upstream-${{ matrix.clang_version }}"
76+
5977
build-windows:
6078
runs-on: windows-latest
6179
steps:
@@ -86,7 +104,11 @@ jobs:
86104
- 17
87105
steps:
88106
- uses: actions/[email protected]
89-
- uses: "./.github/actions/build_debian"
107+
- uses: "./.github/actions/prepare_debian"
90108
with:
91109
install_clang_llvm_org: "${{ matrix.clang_version }}"
92-
job_name: clang_upstream
110+
- uses: ./.github/actions/setup-build-and-test-w-make
111+
with:
112+
save_boost_cache: false
113+
mode_32: false
114+
job_name: "clang_upstream-${{ matrix.clang_version }}"

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ DISABLED_WARNINGS = \
4848
-Wno-unused-value \
4949
-Wno-unused-variable
5050

51-
AM_CXXFLAGS = --std=gnu++17 -O3 -Wall -Werror -Wextra $(DISABLED_WARNINGS) -g
51+
AM_CXXFLAGS = --std=gnu++17 -O3 -Wall -Werror -Wextra $(DISABLED_WARNINGS) -g1
5252

5353
include $(top_srcdir)/Makefile.inc
5454

RELEASE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024-08-22
1+
2024-10-29

libredex/ApkResources.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,6 +2683,9 @@ bool is_inlinable_resource_value(
26832683
android::Res_value* res_value) {
26842684
bool is_not_complex =
26852685
((dtohs(entry->flags) & android::ResTable_entry::FLAG_COMPLEX) == 0);
2686+
if (!is_not_complex) {
2687+
return false;
2688+
}
26862689

26872690
bool is_one_entry = true;
26882691
for (auto& pair : config_to_entry_map) {
@@ -2692,17 +2695,19 @@ bool is_inlinable_resource_value(
26922695
}
26932696
}
26942697
}
2698+
if (!is_one_entry) {
2699+
return false;
2700+
}
26952701

26962702
bool is_valid_type =
26972703
(res_value->dataType == android::Res_value::TYPE_STRING ||
26982704
res_value->dataType == android::Res_value::TYPE_REFERENCE ||
26992705
(res_value->dataType >= android::Res_value::TYPE_FIRST_INT &&
27002706
res_value->dataType <= android::Res_value::TYPE_LAST_INT));
2701-
2702-
if (is_not_complex && is_one_entry && is_valid_type) {
2703-
return true;
2707+
if (!is_valid_type) {
2708+
return false;
27042709
}
2705-
return false;
2710+
return true;
27062711
}
27072712

27082713
/*
@@ -2717,7 +2722,7 @@ ResourcesArscFile::get_inlinable_resource_values() {
27172722
apk::TableEntryParser& parsed_table = table_snapshot.get_parsed_table();
27182723
auto& res_id_to_entries = parsed_table.m_res_id_to_entries;
27192724
std::unordered_map<uint32_t, resources::InlinableValue> inlinable_resources;
2720-
std::vector<std::tuple<uint32_t, android::Res_value*>> past_refs;
2725+
std::unordered_map<uint32_t, uint32_t> past_refs;
27212726

27222727
for (auto& pair : res_id_to_entries) {
27232728
uint32_t id = pair.first;
@@ -2748,8 +2753,7 @@ ResourcesArscFile::get_inlinable_resource_values() {
27482753
}
27492754
val.string_value = chars;
27502755
} else if (res_value->dataType == android::Res_value::TYPE_REFERENCE) {
2751-
past_refs.push_back(
2752-
std::tuple<uint32_t, android::Res_value*>(id, res_value));
2756+
past_refs.insert({id, res_value->data});
27532757
continue;
27542758
} else if (res_value->dataType == android::Res_value::TYPE_INT_BOOLEAN) {
27552759
val.bool_value = res_value->data;
@@ -2762,15 +2766,8 @@ ResourcesArscFile::get_inlinable_resource_values() {
27622766
}
27632767

27642768
// If a reference is found, check if the referenced value is inlinable and add
2765-
// it's actual value to the map (instead of the reference). NOTE: only works
2766-
// if reference only goes down one level.
2767-
for (auto& [id, value] : past_refs) {
2768-
auto it = inlinable_resources.find(value->data);
2769-
if (it != inlinable_resources.end()) {
2770-
resources::InlinableValue val = it->second;
2771-
inlinable_resources.insert({id, val});
2772-
}
2773-
}
2769+
// it's actual value to the map (instead of the reference).
2770+
resources::resources_inlining_find_refs(past_refs, &inlinable_resources);
27742771
return inlinable_resources;
27752772
}
27762773

libredex/BundleResources.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,7 +2405,7 @@ std::unordered_map<uint32_t, resources::InlinableValue>
24052405
ResourcesPbFile::get_inlinable_resource_values() {
24062406
auto& res_id_to_configvalue = m_res_id_to_configvalue;
24072407
std::unordered_map<uint32_t, resources::InlinableValue> inlinable_resources;
2408-
std::vector<std::tuple<uint32_t, uint32_t>> past_refs;
2408+
std::unordered_map<uint32_t, uint32_t> past_refs;
24092409

24102410
for (auto& pair : res_id_to_configvalue) {
24112411
uint32_t id = pair.first;
@@ -2434,7 +2434,7 @@ ResourcesPbFile::get_inlinable_resource_values() {
24342434
resources::InlinableValue inlinable_val{};
24352435
if (item.has_ref()) {
24362436
auto id_to_add = item.ref().id();
2437-
past_refs.push_back(std::tuple<uint32_t, uint32_t>(id, id_to_add));
2437+
past_refs.insert({id, id_to_add});
24382438
continue;
24392439
} else if (item.has_str()) {
24402440
const std::string& og_str = item.str().value();
@@ -2480,13 +2480,7 @@ ResourcesPbFile::get_inlinable_resource_values() {
24802480
// If a reference is found, check if the referenced value is inlinable and add
24812481
// it's actual value to the map (instead of the reference). NOTE: only works
24822482
// if reference only goes down one level.
2483-
for (auto& [id, id_past] : past_refs) {
2484-
auto it = inlinable_resources.find(id_past);
2485-
if (it != inlinable_resources.end()) {
2486-
resources::InlinableValue val = it->second;
2487-
inlinable_resources.insert({id, val});
2488-
}
2489-
}
2483+
resources::resources_inlining_find_refs(past_refs, &inlinable_resources);
24902484
return inlinable_resources;
24912485
}
24922486

libredex/ControlFlow.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,9 +767,14 @@ std::ostream& operator<<(std::ostream& os, const Edge& e) {
767767
return os;
768768
}
769769

770-
case EDGE_THROW:
771-
return os << "throw";
772-
770+
case EDGE_THROW: {
771+
auto catch_type = e.throw_info()->catch_type;
772+
if (catch_type == nullptr) {
773+
return os << "throw";
774+
} else {
775+
return os << "throw " << show(catch_type);
776+
}
777+
}
773778
case EDGE_GHOST:
774779
return os << "ghost";
775780

libredex/DexAccess.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ void loosen_access_modifier_for_vmethods(const DexClasses& scope) {
3939
const auto* method = pair.first;
4040
// If a final method has children, it can only be package-private and we can
4141
// not change it to be public.
42-
if (is_final(method) && !pair.second->children.empty()) {
42+
if (is_final(method) && !pair.second.children.empty()) {
4343
overriden_should_not_be_public(
44-
pair.second.get(), graph.get(), &should_not_mark);
45-
auto& children = pair.second->children;
44+
&pair.second, graph.get(), &should_not_mark);
45+
auto& children = pair.second.children;
4646
auto* first_child = *children.begin();
4747
always_assert_log(!is_public(method) && !is_protected(method),
4848
"%s is visible final but it has children %s",

libredex/DexClass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ std::unique_ptr<DexCode> DexCode::get_dex_code(DexIdx* idx, uint32_t offset) {
641641
always_assert(cdata <= end);
642642
always_assert((uint8_t*)(end) <= idx->end());
643643
while (cdata < end) {
644-
DexInstruction* dop = DexInstruction::make_instruction(idx, &cdata);
644+
DexInstruction* dop = DexInstruction::make_instruction(idx, &cdata, end);
645645
always_assert_log(dop != nullptr,
646646
"Failed to parse method at offset 0x%08x", offset);
647647
dc->m_insns->push_back(dop);

libredex/DexInstruction.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,25 +787,32 @@ void DexInstruction::encode(DexOutputIdx* /* unused */,
787787
size_t DexInstruction::size() const { return m_count + 1; }
788788

789789
DexInstruction* DexInstruction::make_instruction(DexIdx* idx,
790-
const uint16_t** insns_ptr) {
790+
const uint16_t** insns_ptr,
791+
const uint16_t* end) {
791792
auto& insns = *insns_ptr;
792793
auto fopcode = static_cast<DexOpcode>(*insns++);
793794
DexOpcode opcode = static_cast<DexOpcode>(fopcode & 0xff);
794795
switch (opcode) {
795796
case DOPCODE_NOP: {
796797
if (fopcode == FOPCODE_PACKED_SWITCH) {
797798
int count = (*insns--) * 2 + 4;
799+
always_assert(count >= 0);
798800
insns += count;
801+
always_assert(insns <= end);
799802
return new DexOpcodeData(insns - count, count - 1);
800803
} else if (fopcode == FOPCODE_SPARSE_SWITCH) {
801804
int count = (*insns--) * 4 + 2;
805+
always_assert(count >= 0);
802806
insns += count;
807+
always_assert(insns <= end);
803808
return new DexOpcodeData(insns - count, count - 1);
804809
} else if (fopcode == FOPCODE_FILLED_ARRAY) {
805810
uint16_t ewidth = *insns++;
806811
uint32_t size = *((uint32_t*)insns);
807812
int count = (ewidth * size + 1) / 2 + 4;
813+
always_assert(count >= 0);
808814
insns += count - 2;
815+
always_assert(insns <= end);
809816
return new DexOpcodeData(insns - count, count - 1);
810817
}
811818
}

libredex/DexInstruction.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ class DexInstruction : public Gatherable {
8787

8888
public:
8989
static DexInstruction* make_instruction(DexIdx* idx,
90-
const uint16_t** insns_ptr);
90+
const uint16_t** insns_ptr,
91+
const uint16_t* end);
9192
/* Creates the right subclass of DexInstruction for the given opcode */
9293
static DexInstruction* make_instruction(DexOpcode);
9394
virtual void encode(DexOutputIdx* dodx, uint16_t*& insns) const;

libredex/DexPosition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ void RealPositionMapper::write_map_v2() {
397397
uint32_t parent_line = 0;
398398
try {
399399
parent_line = pos->parent == nullptr ? 0 : get_line(pos->parent);
400-
} catch (std::out_of_range& e) {
400+
} catch (std::out_of_range&) {
401401
++unregistered_parent_positions;
402402
TRACE(OPUT, 1, "Parent position %s of %s was not registered",
403403
SHOW(pos->parent), SHOW(pos));

0 commit comments

Comments
 (0)