wakatime/wakatime-cli

Process freezes while trying to parse large binary file

es3n1n opened this issue · 4 comments

es3n1n commented

As you may know, there is a Wakatime plugin for the hexrays product IDA Pro, and IDA Pro stores the project info in their custom binary format, and often this file could reach a very huge size. Lately, we've been getting system crashes because wakatime-cli process keeps running with 4gbs of allocated memory, each time you make a change in your project, the new instance of wakatime-cli spawns and starts to eat your memory, resulting in a system crash(and a project changes loss too).

So what I did is I grabbed the arguments that are getting passed to wakatime-cli and tried to just run it within my python script

from subprocess import Popen
from subprocess import PIPE
from pathlib import Path


def launch(*args):
    x = Popen(args, stdout=PIPE, stderr=PIPE)
    x.wait()
    print(x.stdout.read())


wakatime_cli_path = Path('C:\\Users\\retard\\.wakatime\\wakatime-cli-windows-amd64.exe')


while True:
    launch(
        str(wakatime_cli_path.absolute()),
        '--entity', 'SomeEntity',
        '--time', '1694564455.902440',
        '--plugin', 'ida-pro/7.7 ida-pro-wakatime/1.0',
        '--local-file', 'D:\\test.i64',
        '--alternate-language', 'IDA',
        '--category', '"code reviewing"',
        '--key', 'redacted',
        '--alternate-project', 'test.i64'
    )

That's how i confirmed that when i remove the local-file path it works just fine.

When the process froze I checked the opened handles and found the handle to the file, considering that i think you guys can add some flag that would disable all the logic related to this file. I uploaded a .i64 file that causes the process to allocate the memory for it and just freeze, you can try to pass it to the wakatime-cli and you'll see what i mean.

Expected behavior (what should have happened): wakatime-cli should send the heartbeat and gracefully exit without eating your whole ram

Actual behavior (what went wrong): wakatime-cli keeps running resulting in many instances running at the same time and the system crashes with a blue screen on Windows :^)

Environment:

  • OS: tested only on windows64
  • Platform: amd64

Logs:
there's none

@es3n1n I can't download that file as it's broken for me. Is there another way to share with us? Maybe WeTransfer?

es3n1n commented

@es3n1n I can't download that file as it's broken for me. Is there another way to share with us? Maybe WeTransfer?

Reuploaded it to the WeTransfer

A new lexer is needed in order to avoid wakatime-cli detecting it as Objective C and hanging forever trying to read it. As soon as this PR gets merged and released you'll need to close the IDE and reopen to update the cli version.

es3n1n commented

Can confirm that everything works as expected on the latest preview release