bug with command line "eventghost.exe -e"

Found a bug in EventGhost? Report it here.
Snowbird
Experienced User
Posts: 292
Joined: Fri Jul 03, 2009 10:04 am

Re: bug with command line "eventghost.exe -e"

Post by Snowbird » Wed Dec 06, 2017 9:02 am

Hi,

just to let you know that it has been 48h that it is running without a single hitch ! :) so we can definitively say that it's completely fixed ! Because it has never worked for so long without throwing an error and/or running multiple EG processes at the same time.

good job Kev. :wink:

Thank you !

Snowbird
Experienced User
Posts: 292
Joined: Fri Jul 03, 2009 10:04 am

Re: bug with command line "eventghost.exe -e"

Post by Snowbird » Wed Dec 06, 2017 1:15 pm

NOoooooooooooooooooooooo :)

just had the bug of 2 EG processes ! :shock: :shock:
I can't believe it... i really thought it was solved for good.... sorry for the bad news ! it looks like there is some more tuning to be made.

User avatar
kgschlosser
Site Admin
Posts: 3707
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: bug with command line "eventghost.exe -e"

Post by kgschlosser » Wed Dec 06, 2017 3:12 pm

i am hoping you were running EG in debugging mode during this and have some log output for me :-D
If you like the work I have been doing then feel free to Image

Snowbird
Experienced User
Posts: 292
Joined: Fri Jul 03, 2009 10:04 am

Re: bug with command line "eventghost.exe -e"

Post by Snowbird » Wed Dec 06, 2017 4:32 pm

Ok, now I feel bad :D I can hear you laughing :p

I don't know for what reason I disabled it.... probably playing with it and forgot to enable it back ...

it's on now, let's wait again :)

User avatar
kgschlosser
Site Admin
Posts: 3707
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: bug with command line "eventghost.exe -e"

Post by kgschlosser » Wed Dec 06, 2017 5:35 pm

i had a funny feeling you were going to say it was turned off.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 3707
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: bug with command line "eventghost.exe -e"

Post by kgschlosser » Tue Dec 19, 2017 3:29 am

OK so I wanted to let you know I have been working on this issue. I have finally caused the error to happen. and I know how to cause it to happen at any time.

Now I have fixed the issue but it kind of has a side affect. and that side affect is this..as a test setup what i did was i created a python script that would run EG with the -event switch. when i juice up the speed on it. say... to make the call once every 50 milliseconds or so. the events don't get fired in succession..


so if i tell it to run EG 100 times and i supply the count to the event the numbers are not in order. This I am trying to hammer out how to fix. so it shouldn't be long until i get it to work properly.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 3707
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: bug with command line "eventghost.exe -e"

Post by kgschlosser » Tue Dec 19, 2017 6:07 am

YAY!!! I beat this problem down with a stick...


So I am almost 100% I have gotten this issue sorted.. It's amazing what being able to reproduce the error does. It makes it ooooo so much easier. I was never one to simply throw things at a problem blindly. Tho i did have the correct assessment of the problem. Just that the problem wasn't located where I thought it was.

The issue was that the named pipe couldn't create it's self fast enough before the second query came in. The first query checking to see if EG was already running. and the second was to trigger the event. before the Named pipe could recreate it's self the trigger event command came in and would error out.

So this is what I have done to handle this. I have learned a whole lot about named pipes including the ability to use the same pipe as many times as I want simultaneously. Which is a good and a bad thing. Because I do not want more then is necessary kicking about it will only keep one spare waiting for a connection at any given point in time but it will dynamically create new ones as fast as you can spout commands into EG. i HAVE eg create a new thread for each running pipe to handle anything that comes into it. I had to do it this way because when you go to read the pipe to see if there is any data in it it blocks anything else from happening and i wanted to be able to read from more then one pipe at a time so hence a thread for each. so they can block away and it will not affect anything else. once the pipe has read data from the pipe it sets a flag to indicate that it is no longer waiting but is not processing. and because of this flag being set if the backup pipe gets a connection and reads data it will see there are no available pipes. so it will then create another pipe. when that backup pipe is finished it will destroy it's self because it has made it's replacement. and the first pipe will also check to see if there are available pipes and if not it will create a new one as well. so at any given point there should be a max of 3 pipes waiting for connections.

now because of how this is handled if you triggered 10 events they would not show up in order. so I had to create a processing thread that would make sure that things were put back into order. Now there is a sync issue when you go below 20 milliseconds. But I think that 20 milliseconds between firing an event from the command line is acceptable. I have tested this with firing off 1000 events. this is the limit of my computer at 23 megs of ram per instance that's about 23 gig in the memory department. (i think.... been a long day)

The attached file should fix the issue. I will be submitting this to be added to the core code.
Attachments
NamedPipe.py
(15.66 KiB) Downloaded 57 times
If you like the work I have been doing then feel free to Image

Snowbird
Experienced User
Posts: 292
Joined: Fri Jul 03, 2009 10:04 am

Re: bug with command line "eventghost.exe -e"

Post by Snowbird » Tue Dec 19, 2017 8:28 am

I don't know what to say.... you're really nice and good at what you do !! Thank you for this in-depth explanation, I understand much better the "why" and the solution !

I replaced the file, but for some reason now EG consumes 50% of my CPU :shock: , it's running in a VM but still, with the previous file (or even the original RC4 file) I didn't have this odd behavior, never had more than 2 or 3% consumed while EG is not doing anything. I think to be able to reproduce this you need a slow computer, or a VM just like me.

If you need me to test anything let me know.

User avatar
kgschlosser
Site Admin
Posts: 3707
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: bug with command line "eventghost.exe -e"

Post by kgschlosser » Tue Dec 19, 2017 1:07 pm

Ahhhh poop. I forgot to institute a sleep in it.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 3707
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: bug with command line "eventghost.exe -e"

Post by kgschlosser » Tue Dec 19, 2017 2:15 pm

OK i fixed the high CPU use and I also ran a few more tests on it. the fastest my specific machine will allow for is 0.0352 seconds between triggering events. if i go any faster it does not make an impact on how fast it can process them. But i can rack off 100 events in 4.9 seconds (I know the math doesn't add but you have to remember there is some processing overhead). so i think at 35 milliseconds that is pretty decent.

attached is the new version with the high CPU fixed. Now remember if you spit out 100 events at EG like i was the CPU use is going to jump up. I am going to remove one thing from the named pip. so this is not done yet. But it is very close to being finished up which is a good thing.
Attachments
NamedPipe.py
(17.57 KiB) Downloaded 62 times
If you like the work I have been doing then feel free to Image

Snowbird
Experienced User
Posts: 292
Joined: Fri Jul 03, 2009 10:04 am

Re: bug with command line "eventghost.exe -e"

Post by Snowbird » Tue Dec 19, 2017 2:31 pm

Problem is fixed !! good job ;)

the only thing that is intriguing me is the NamedPipe.py file size, it used to be around 10KB, and now it's almost 18KB :) it looks like it's a huge fix !! ;)

Thank you !

Snowbird
Experienced User
Posts: 292
Joined: Fri Jul 03, 2009 10:04 am

Re: bug with command line "eventghost.exe -e"

Post by Snowbird » Tue Dec 19, 2017 2:45 pm

oh by the way, do you think that the "-netsend" switch is also affected with this bug ? I didn't use it recently so I can't tell, but since the mechanism is almost the same as with the "-event" switch, I was wondering ? any thoughts on this ?

User avatar
kgschlosser
Site Admin
Posts: 3707
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: bug with command line "eventghost.exe -e"

Post by kgschlosser » Tue Dec 19, 2017 3:16 pm

any command that would be sent to an already running instance of EG would have been affected. This would fix all of them. so if you used the -hide switch and EG was already running it would affect it..


which BTW does hide EG if it is already running. :-D

I have also managed to get some mroe speed out of the pipe. about 1/2 a second when triggering 100 events. it now takes 4.5 seconds on my machine. which if you think about it is not all that bad because it has to start 100 sessions of EG. I do think 4.5 seconds to start EG 100 times and to send the trigger event command 100 times is pretty good if i do say so myself.

I am going to submit this new change as a PR. I am not sure if it will get into the next release. Tho it is a better solution and less error prone. so there is a good possibility it will make it in.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 3707
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: bug with command line "eventghost.exe -e"

Post by kgschlosser » Thu Apr 19, 2018 7:01 am

OK i have done some work on this as it appears some folks were still having issues.

I wrote a pure python implementation dealing with windows named pipes. This is what i have managed to do.


if i start 5000 threads one right after the other and each one makes a connection and then sends 1000 messages and receives 1000 messages it does this in 3 minutes and 45 seconds.

if i start 1000 threads and stall them until all threads are started and then let them loose this makes 1000 concurrent connections to the named pipe server. it does the same 1000 sends and 1000 receives. and it does this in 35 seconds.

The news is it does both of these scenarios with 0% data loss and 0% errors. you are talking 10000000 transfers through the pipe in the first setup. and 2000000 concurrent on the second. now that my friends is a solid piece of code.

I have to create security descriptors and remove the old named pipe and install this version into EG. But this should remove any further issues
If you like the work I have been doing then feel free to Image

Snowbird
Experienced User
Posts: 292
Joined: Fri Jul 03, 2009 10:04 am

Re: bug with command line "eventghost.exe -e"

Post by Snowbird » Thu Apr 19, 2018 7:12 am

that's a very good news :) if you want me to test it just let me know, since I'm concerned by this "bug" almost daily, I can tell you right away if there is improvement on my end ;)

thanks !

Post Reply