[Galaxy S 4 i9505 Original Android Development] chenxiaolong:
Thanks for catching that!

It's segfaulting though, which is worrisome. I don't think my code has been bad enough to let that happen for a while :D I'll do some debugging and let you know what I find.

EDIT: Fixed in 8.0.0.r1592.gad833e7! This was why: when the patcher is searching for functions in the updater-script, it updated the starting point of the range, but not the ending point. At the end of the log, you can see it started searching from 226 until it reached 221, which is an infinite loop. Eventually, it started reading out of bounds and crashed.

...
210: String : ui_print
211: LeftParen : (
212: String : "@Complete!!"
213: RightParen : )
214: Semicolon : ;
215: Newline :

216: String : unmount
217: LeftParen : (
218: String : "/system"
219: RightParen : )
220: Semicolon : ;
FINDING FUNCTION BEGINNING AT 0 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 4 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 10 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 16 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 22 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 28 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 34 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 40 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 46 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 52 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 58 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 64 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 70 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 79 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 85 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 100 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 107 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 116 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 152 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 188 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 195 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 202 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 208 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 214 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 226 AND ENDING AT 221

chenxiaolong@cxl-4270cto build_linux_x86_64/DualBootPatcher-8.99.10-Linux (master *%) » valgrind ./a.out zerolte multi-slot-1 /stuff/Android/DualBoot/zerolte/EA-G920T-G920W8-ONLY-CSFIX-1.0.zip
==9437== Memcheck, a memory error detector
==9437== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==9437== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==9437== Command: ./a.out zerolte multi-slot-1 /stuff/Android/DualBoot/zerolte/EA-G920T-G920W8-ONLY-CSFIX-1.0.zip
==9437==
0: String : ui_print
1: LeftParen : (
2: String : ""
3: RightParen : )
4: Semicolon : ;
5: Newline :

6: String : ui_print
7: LeftParen : (
8: String : "___________ "
9: RightParen : )
10: Semicolon : ;
11: Newline :

12: String : ui_print
13: LeftParen : (
14: String : "\_ _____/ "
15: RightParen : )
16: Semicolon : ;
17: Newline :

18: String : ui_print
19: LeftParen : (
20: String : " | __)_ "
21: RightParen : )
22: Semicolon : ;
23: Newline :

24: String : ui_print
25: LeftParen : (
26: String : " | \ "
27: RightParen : )
28: Semicolon : ;
29: Newline :

30: String : ui_print
31: LeftParen : (
32: String : "/_______ / mporia "
33: RightParen : )
34: Semicolon : ;
35: Newline :

36: String : ui_print
37: LeftParen : (
38: String : " \/ "
39: RightParen : )
40: Semicolon : ;
41: Newline :

42: String : ui_print
43: LeftParen : (
44: String : "ENABLE CALL SOUND "
45: RightParen : )
46: Semicolon : ;
47: Newline :

48: String : ui_print
49: LeftParen : (
50: String : "G90T & G920W8 ONLY! "
51: RightParen : )
52: Semicolon : ;
53: Newline :

54: String : ui_print
55: LeftParen : (
56: String : "CREDIT g.lewarne AND -Mr. X- "
57: RightParen : )
58: Semicolon : ;
59: Newline :

60: String : ui_print
61: LeftParen : (
62: String : "BY iB4STiD VERSION 1.0 "
63: RightParen : )
64: Semicolon : ;
65: Newline :

66: String : ui_print
67: LeftParen : (
68: String : ""
69: RightParen : )
70: Semicolon : ;
71: Newline :

72: Newline :

73: String : show_progress
74: LeftParen : (
75: String : 0.7
76: Comma : ,
77: String : 1380
78: RightParen : )
79: Semicolon : ;
80: Newline :

81: String : ui_print
82: LeftParen : (
83: String : "- Mounting system"
84: RightParen : )
85: Semicolon : ;
86: Newline :

87: String : run_program
88: LeftParen : (
89: String : "/sbin/mount"
90: Comma : ,
91: Whitespace :
92: String : "-t"
93: Comma : ,
94: Whitespace :
95: String : "auto"
96: Comma : ,
97: Whitespace :
98: String : "/system"
99: RightParen : )
100: Semicolon : ;
101: Newline :

102: Newline :

103: String : ui_print
104: LeftParen : (
105: String : "- Writing mod"
106: RightParen : )
107: Semicolon : ;
108: Newline :

109: String : package_extract_dir
110: LeftParen : (
111: String : "system"
112: Comma : ,
113: Whitespace :
114: String : "/system"
115: RightParen : )
116: Semicolon : ;
117: Newline :

118: String : set_metadata
119: LeftParen : (
120: String : "/system/bin/rild"
121: Comma : ,
122: Whitespace :
123: String : "uid"
124: Comma : ,
125: Whitespace :
126: String : 0
127: Comma : ,
128: Whitespace :
129: String : "gid"
130: Comma : ,
131: Whitespace :
132: String : 2000
133: Comma : ,
134: Whitespace :
135: String : "mode"
136: Comma : ,
137: Whitespace :
138: String : 0755
139: Comma : ,
140: Whitespace :
141: String : "capabilities"
142: Comma : ,
143: Whitespace :
144: String : 0x0
145: Comma : ,
146: Whitespace :
147: String : "selabel"
148: Comma : ,
149: Whitespace :
150: String : "u:object_r:rild_exec:s0"
151: RightParen : )
152: Semicolon : ;
153: Newline :

154: String : set_metadata
155: LeftParen : (
156: String : "/system/bin/cellgeofenced"
157: Comma : ,
158: Whitespace :
159: String : "uid"
160: Comma : ,
161: Whitespace :
162: String : 0
163: Comma : ,
164: Whitespace :
165: String : "gid"
166: Comma : ,
167: Whitespace :
168: String : 2000
169: Comma : ,
170: Whitespace :
171: String : "mode"
172: Comma : ,
173: Whitespace :
174: String : 0755
175: Comma : ,
176: Whitespace :
177: String : "capabilities"
178: Comma : ,
179: Whitespace :
180: String : 0x0
181: Comma : ,
182: Whitespace :
183: String : "selabel"
184: Comma : ,
185: Whitespace :
186: String : "u:object_r:cellgeofenced_exec:s0"
187: RightParen : )
188: Semicolon : ;
189: Newline :

190: Newline :

191: String : ui_print
192: LeftParen : (
193: String : "- Done, Enjoy Arcadia!"
194: RightParen : )
195: Semicolon : ;
196: Newline :

197: Newline :

198: String : ui_print
199: LeftParen : (
200: String : ""
201: RightParen : )
202: Semicolon : ;
203: Newline :

204: String : set_progress
205: LeftParen : (
206: String : 1.0
207: RightParen : )
208: Semicolon : ;
209: Newline :

210: String : ui_print
211: LeftParen : (
212: String : "@Complete!!"
213: RightParen : )
214: Semicolon : ;
215: Newline :

216: String : unmount
217: LeftParen : (
218: String : "/system"
219: RightParen : )
220: Semicolon : ;
FINDING FUNCTION BEGINNING AT 0 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 4 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 10 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 16 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 22 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 28 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 34 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 40 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 46 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 52 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 58 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 64 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 70 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 79 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 85 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 100 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 107 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 116 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 152 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 188 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 195 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 202 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 208 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 214 AND ENDING AT 221
FINDING FUNCTION BEGINNING AT 226 AND ENDING AT 221
==9437== Use of uninitialised value of size 8
==9437== at 0x4EDBB92: mbp::EdifyToken::type() const (tokenizer.cpp:40)
==9437== by 0x4EE42A3: mbp::findFunction(__gnu_cxx::__normal_iterator<mbp::EdifyToken**, std::vector<mbp::EdifyToken*, std::allocator<mbp::EdifyToken*> > >, __gnu_cxx::__normal_iterator<mbp::EdifyToken**, std::vector<mbp::EdifyToken*, std::allocator<mbp::EdifyToken*> > >, __gnu_cxx::__normal_iterator<mbp::EdifyToken**, std::vector<mbp::EdifyToken*, std::allocator<mbp::EdifyToken*> > >*, __gnu_cxx::__normal_iterator<mbp::EdifyToken**, std::vector<mbp::EdifyToken*, std::allocator<mbp::EdifyToken*> > >*, __gnu_cxx::__normal_iterator<mbp::EdifyToken**, std::vector<mbp::EdifyToken*, std::allocator<mbp::EdifyToken*> > >*) (standardpatcher.cpp:113)
==9437== by 0x4EE6652: mbp::StandardPatcher::patchFiles(std::string const&) (standardpatcher.cpp:646)
==9437== by 0x4EEBA79: mbp::MultiBootPatcher::Impl::pass2(TagzipFile__*, std::string const&, std::unordered_set<std::string, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::string> > const&) (multibootpatcher.cpp:515)
==9437== by 0x4EEAABC: mbp::MultiBootPatcher::Impl::patchZip() (multibootpatcher.cpp:330)
==9437== by 0x4EE9DF4: mbp::MultiBootPatcher::patchFile(void (*)(unsigned long, unsigned long, void*), void (*)(unsigned long, unsigned long, void*), void (*)(std::string const&, void*), void*) (multibootpatcher.cpp:171)
==9437== by 0x401BA9: main (in /stuff/Android/DualBootPatcher/build_linux_x86_64/DualBootPatcher-8.99.10-Linux/a.out)
==9437==
==9437== Invalid read of size 4
==9437== at 0x4EDBB92: mbp::EdifyToken::type() const (tokenizer.cpp:40)
==9437== by 0x4EE42A3: mbp::findFunction(__gnu_cxx::__normal_iterator<mbp::EdifyToken**, std::vector<mbp::EdifyToken*, std::allocator<mbp::EdifyToken*> > >, __gnu_cxx::__normal_iterator<mbp::EdifyToken**, std::vector<mbp::EdifyToken*, std::allocator<mbp::EdifyToken*> > >, __gnu_cxx::__normal_iterator<mbp::EdifyToken**, std::vector<mbp::EdifyToken*, std::allocator<mbp::EdifyToken*> > >*, __gnu_cxx::__normal_iterator<mbp::EdifyToken**, std::vector<mbp::EdifyToken*, std::allocator<mbp::EdifyToken*> > >*, __gnu_cxx::__normal_iterator<mbp::EdifyToken**, std::vector<mbp::EdifyToken*, std::allocator<mbp::EdifyToken*> > >*) (standardpatcher.cpp:113)
==9437== by 0x4EE6652: mbp::StandardPatcher::patchFiles(std::string const&) (standardpatcher.cpp:646)
==9437== by 0x4EEBA79: mbp::MultiBootPatcher::Impl::pass2(TagzipFile__*, std::string const&, std::unordered_set<std::string, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::string> > const&) (multibootpatcher.cpp:515)
==9437== by 0x4EEAABC: mbp::MultiBootPatcher::Impl::patchZip() (multibootpatcher.cpp:330)
==9437== by 0x4EE9DF4: mbp::MultiBootPatcher::patchFile(void (*)(unsigned long, unsigned long, void*), void (*)(unsigned long, unsigned long, void*), void (*)(std::string const&, void*), void*) (multibootpatcher.cpp:171)
==9437== by 0x401BA9: main (in /stuff/Android/DualBootPatcher/build_linux_x86_64/DualBootPatcher-8.99.10-Linux/a.out)
==9437== Address 0x8 is not stack'd, malloc'd or (recently) free'd
==9437==
==9437==
==9437== Process terminating with default action of signal 11 (SIGSEGV)
==9437== Access not within mapped region at address 0x8
==9437== at 0x4EDBB92: mbp::EdifyToken::type() const (tokenizer.cpp:40)
==9437== by 0x4EE42A3: mbp::findFunction(__gnu_cxx::__normal_iterator<mbp::EdifyToken**, std::vector<mbp::EdifyToken*, std::allocator<mbp::EdifyToken*> > >, __gnu_cxx::__normal_iterator<mbp::EdifyToken**, std::vector<mbp::EdifyToken*, std::allocator<mbp::EdifyToken*> > >, __gnu_cxx::__normal_iterator<mbp::EdifyToken**, std::vector<mbp::EdifyToken*, std::allocator<mbp::EdifyToken*> > >*, __gnu_cxx::__normal_iterator<mbp::EdifyToken**, std::vector<mbp::EdifyToken*, std::allocator<mbp::EdifyToken*> > >*, __gnu_cxx::__normal_iterator<mbp::EdifyToken**, std::vector<mbp::EdifyToken*, std::allocator<mbp::EdifyToken*> > >*) (standardpatcher.cpp:113)
==9437== by 0x4EE6652: mbp::StandardPatcher::patchFiles(std::string const&) (standardpatcher.cpp:646)
==9437== by 0x4EEBA79: mbp::MultiBootPatcher::Impl::pass2(TagzipFile__*, std::string const&, std::unordered_set<std::string, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::string> > const&) (multibootpatcher.cpp:515)
==9437== by 0x4EEAABC: mbp::MultiBootPatcher::Impl::patchZip() (multibootpatcher.cpp:330)
==9437== by 0x4EE9DF4: mbp::MultiBootPatcher::patchFile(void (*)(unsigned long, unsigned long, void*), void (*)(unsigned long, unsigned long, void*), void (*)(std::string const&, void*), void*) (multibootpatcher.cpp:171)
==9437== by 0x401BA9: main (in /stuff/Android/DualBootPatcher/build_linux_x86_64/DualBootPatcher-8.99.10-Linux/a.out)
==9437== If you believe this happened as a result of a stack
==9437== overflow in your program's main thread (unlikely but
==9437== possible), you can try to increase the size of the
==9437== main thread stack using the --main-stacksize= flag.
==9437== The main thread stack size used in this run was 8388608.
==9437==
==9437== HEAP SUMMARY:
==9437== in use at exit: 188,418 bytes in 1,065 blocks
==9437== total heap usage: 3,000 allocs, 1,935 frees, 49,401,652 bytes allocated
==9437==
==9437== LEAK SUMMARY:
==9437== definitely lost: 0 bytes in 0 blocks
==9437== indirectly lost: 0 bytes in 0 blocks
==9437== possibly lost: 27,356 bytes in 621 blocks
==9437== still reachable: 161,062 bytes in 444 blocks
==9437== suppressed: 0 bytes in 0 blocks
==9437== Rerun with --leak-check=full to see details of leaked memory
==9437==
==9437== For counts of detected and suppressed errors, rerun with: -v
==9437== Use --track-origins=yes to see where uninitialised values come from
==9437== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
[1] 9437 segmentation fault (core dumped) valgrind ./a.out zerolte multi-slot-1