No offense taken. All valid points and some good ideas. I will try them. I apologize for the wall of text below. I was trying to avoid this, but since I have you concerned and confused, I felt maybe it was necessary.
My goal is this:
- Do the work of debugging this myself so that I’m not submitting an erroneous bug report. Also verify this is not a problem with my approach. Which is most likely the case.
- Not ask anyone else to do it for me, which is why i left some details out. Did not want to waste anyone’s time.
- Generate a smaller example of code before pasting it into the forums. Thought it would be easier to evaluate for further questions and learning. Since I have not yet found a way to reduce this to a smaller snippet, and I’ve been asked for more details, excerpts from my code is below.
- My requirements for generating test data comes from the idea that a known byte array constant is more likely to be easily dealt with by the context allocator (and also by me) than a dynamically created byte array of potentially varying size.
Description of Problem
I have a program that parses and executes on several “switches” read from os.args. Sometimes expected data is not output to the terminal.
Each command does the following:
- Executes an external tool
- Receives data from a remote host
- Processes the returned byte array data
- Outputs the results
- Program exits
More specifically, if 3 specific commands are processed together, I sometimes see output for all 3, and most of the time only see output for 1 and 2, where 3 is missing. If I “slap” a tracking allocator on top, all 3 successfully output every time. Additionally, the tracking allocator does not capture any allocations not freed, or any incorrect frees.
So far I have tried the following:
- Place a time delay between each command to rule out network latency and host processing latency. A delay of up to 5 seconds does not change the behavior. So i believe latency is not the issue. Also with the tracking allocator and no time delay in between, I can run the program with the same commands over and over in fast succession with consistent output. (i.e. up arrow enter, up arrow enter…)
- Define every command with their own distinct variable name and separate out reuse of variables as a potential issue. Still no change in behavior. Not convinced I ruled variable reuse out, but I’m leaning in that direction.
Details of Execution:
Command 1
adb.exec.command = { "adb", "shell", "pm", "list", "packages", "-3" }
exec_command(&adb, pf)
packages, p_ok := bytes_remove_string(adb.stdout, "package:")
delete_process(&adb)
adb.exec.command = {"adb", "shell", "ps", "-o", "ARGS=CMD"}
exec_command(&adb, pf)
running_packages := bytes.split(adb.stdout, {'\n'})
delete_process(&adb)
printfcln(pf.title, "%s", "Running User Installed (3rd Party) Packages:")
for running in running_packages {
if bytes.contains(packages, running) {
printfcln(pf.data, "%s", running)
}
}
delete(running_packages)
if p_ok do delete(packages)
Command 2
adb.exec.command = {"adb", "shell", "dumpsys", "diskstats"}
exec_command(&adb, pf)
parse_system_data_sizes(adb.stdout, pf) // outputs to terminal when done
delete_process(&adb)
Command 3
adb.exec.command = { "adb", "shell", "pm", "list", "packages", "-3" }
exec_command(&adb, pf)
user_packages, up_ok := bytes_remove_string(adb.stdout, "package:")
delete_process(&adb)
adb.exec.command = {"adb", "shell", "pm", "list", "packages", "-s"}
exec_command(&adb, pf)
system_packages, sp_ok := bytes_remove_string(adb.stdout, "package:")
delete_process(&adb)
if bytes_contains_string(user_packages, os.args[idx+1]) || bytes_contains_string(system_packages, os.args[idx+1]) {
adb.exec.command = {"adb", "shell", "dumpsys", "diskstats"}
exec_command(&adb, pf)
parse_package_size(adb.stdout, os.args[idx+1], pf) // outputs to terminal when done
delete_process(&adb)
}
if up_ok do delete(user_packages)
if sp_ok do delete(system_packages)
System, Versions, etc.
odin dev-2025-11-nightly
Kubuntu 25.10
kernel 6.17