mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Software (https://www.mersenneforum.org/forumdisplay.php?f=10)
-   -   ntdll.dll error when starting Prime95 from a task scheduler action (https://www.mersenneforum.org/showthread.php?t=24235)

pokemonlover123 2019-03-28 14:13

ntdll.dll error when starting Prime95 from a task scheduler action
 
I am on a laptop and run Prime95 (and mfaktc) whenever I plug in my laptop. After a bit of research, I managed to create a task scheduler entry with a custom event filter that listens for KernelPower event id 105 (source change) and checks if event data AcPower is true, if this gets triggered, I have it run mfaktc and prime95. mfaktc works fine, however prime95 never starts and after looking in event viewer, I see its faulting from ntdll.dll. It works perfectly fine if I start the program normally. Is it a bug? Or an issue with my task scheduler entry config?

pokemonlover123 2019-03-28 14:16

I'll add relevant screenshots with more info in about an hour

pokemonlover123 2019-03-28 14:54

First five screenshots
 
5 Attachment(s)
This post contains the first 5 screenshots relevant to the issue. Device specs and part of the task scheduler entry configuration are included.

pokemonlover123 2019-03-28 14:58

Rest of screenshots
 
3 Attachment(s)
Remaining task scheduler entry pages, and the crash log for Prime95 in event viewer.

sdbardwick 2019-03-28 15:42

No thoughts on your exact error, but perhaps an end run around it: Prime95 offers the option to stop when on battery power - checkbox in Options->Preferences menu. I'd check functionality of the menu option and see if it moots the problem.

pokemonlover123 2019-03-28 15:45

Another potential workaround
 
[QUOTE=sdbardwick;512047]No thoughts on your exact error, but perhaps an end run around it: Prime95 offers the option to stop when on battery power - checkbox in Options->Preferences menu. I'd check functionality of the menu option and see if it moots the problem.[/QUOTE]

That could work. But I prefer Smart Guy solutions :geek: (Honestly I really put a lot of hard work on myself and always choose the hardest solutions sooo... Kinda kicking myself here)

I could try having the action launch Prime95 indirectly by having it run a batch file that runs Prime95 and see if that works.

pokemonlover123 2019-03-28 15:51

Not a race condition
 
I tried removing mfaktc from the action list to see if a race condition was happening and both programs were trying to access the same memory or something. No difference.

kriesel 2019-03-28 18:28

Try creating and launching a batch wrapper for prime95.
[I]cmd /k (full path)(batchfile)[/I]
(/k means keep; launch window hangs around afterward to display any launch related error messages sent to stderr until you explicitly close it)

The batch file can contain explicit
[I]cd <working directory> [/I]
where the dlls, config files, prime95.exe, savefiles etc are
[I]start prime95.exe[/I]
(launches the app and immediately returns to the batch file for the next step) or
[I]prime95.exe [/I]
(waits for the named app to terminate)

Also for troubleshooting the batch file is a place to add set, dir /q /a commands etc temporarily such as for troubleshooting permissions & ownership of the process and files. On some OS versions the process properties of the batch file are not those of the interactive or other process that launched it unless you take steps to ensure that.

Initially this approach may be clunky/cluttered. After you get it working, then you may be able to prune off some of it, a bit at a time, by initially commenting out a bit, in case that's the line that if absent breaks it, or will prove useful again later.

I'd be inclined to prefix mfaktc.exe with cmd /k for some of the same reasons.

pokemonlover123 2019-03-28 19:02

[QUOTE=kriesel;512057]Try creating and launching a batch wrapper for prime95.
[I]cmd /k (full path)(batchfile)[/I]
(/k means keep; launch window hangs around afterward to display any launch related error messages sent to stderr until you explicitly close it)

The batch file can contain explicit
[I]cd <working directory> [/I]
where the dlls, config files, prime95.exe, savefiles etc are
[I]start prime95.exe[/I]
(launches the app and immediately returns to the batch file for the next step) or
[I]prime95.exe [/I]
(waits for the named app to terminate)

Also for troubleshooting the batch file is a place to add set, dir /q /a commands etc temporarily such as for troubleshooting permissions & ownership of the process and files. On some OS versions the process properties of the batch file are not those of the interactive or other process that launched it unless you take steps to ensure that.

Initially this approach may be clunky/cluttered. After you get it working, then you may be able to prune off some of it, a bit at a time, by initially commenting out a bit, in case that's the line that if absent breaks it, or will prove useful again later.

I'd be inclined to prefix mfaktc.exe with cmd /k for some of the same reasons.[/QUOTE]
When using the batch file solution it works fine. Nothing to debug since the bug doesn't happen. Seems entirely related to task scheduler starting the process. Just the cmd /k prime95.exe and setting working directory in the task scheduler to the prime95 directory works perfectly. I don't know how to figure out what goes wrong with the task scheduler action, as I don't know how task scheduler runs actions. And that may be related to the issue. It's also weird that mfaktc displays no such issue. My original suspicion was that it had something to do with how Prime95 defaults to opening in the tray. Is there a way to disable that? I was unable to find the configuration value for it.

kriesel 2019-03-28 19:18

[QUOTE=pokemonlover123;512060]When using the batch file solution it works fine. Nothing to debug since the bug doesn't happen. Seems entirely related to task scheduler starting the process. Just the cmd /k prime95.exe and setting working directory in the task scheduler to the prime95 directory works perfectly. I don't know how to figure out what goes wrong with the task scheduler action, as I don't know how task scheduler runs actions. And that may be related to the issue. It's also weird that mfaktc displays no such issue. My original suspicion was that it had something to do with how Prime95 defaults to opening in the tray. Is there a way to disable that? I was unable to find the configuration value for it.[/QUOTE]
In Prime95, Options, uncheck Tray Icon.
An obvious difference is prime95 has Windows GUI code and mfaktc is command line.

Note, a web search for 0xc0000005 leads to some serious system diagnostics recommendations. Might want to be proactive on backups and system checks, just in case, before your bits hit the fan.

pokemonlover123 2019-03-28 19:27

[QUOTE=kriesel;512063]In Prime95, Options, uncheck Tray Icon.
An obvious difference is prime95 has Windows GUI code and mfaktc is command line.

Note, a web search for 0xc0000005 leads to some serious system diagnostics recommendations. Might want to be proactive on backups and system checks, just in case, before your bits hit the fan.[/QUOTE]

Yeah, I've already looked that up. Apparently, it's an access violation, which I find weird. Why would Prime95 cause an access violation from being run from a task scheduler action as opposed to manually or even from the command line? It's almost like task scheduler does something a [I]tiny[/I] bit differently and that causes an issue. I'll keep looking into it. Currently running an SFC.

pokemonlover123 2019-03-28 19:36

No Dice
 
SFC returned no integrity violation and the no tray selection didn't do anything. I'll continue doing research.

pokemonlover123 2019-03-28 19:58

Okay so I found something weird. It seems that the process starts Prime95 fine, because it shows up in task manager and it disappears properly when I unplug (I have it set to stop when I switch back to battery power). The process starts, and it isn't a ghost process. However, the access violation keeps it from ever actually doing stuff. The icon never appears and it never does any calculations, and then it stops after about 10-15 seconds. All this leads me to think it's either a windows bug or a prime95 bug. Trying to come up with a way to debug.

Uncwilly 2019-03-28 22:15

Where are your data files for Prime95? If they are in Program Files, that might be your issue.

pokemonlover123 2019-03-28 22:32

All of the data files are in a folder on my desktop. The task scheduler has working dir set to that folder. All files are owned by my user account, which is also the account the task is run under.

pokemonlover123 2019-03-28 22:37

This is most likely a bug
 
At this point I'm convinced this is a bug and not a problem with my computer or my configuration. I think I'm gonna email a bug report to George Woltmann tomorrow (as specified on the bottom of the software download page) and get some developer input on this. Hopefully they can figure out what's actually going wrong.

Uncwilly 2019-03-28 22:39

He is here on the forum. He just might not have logged in yet.

pokemonlover123 2019-03-28 22:41

Oh yeah. He's the Prime95 account right? Hopefully he'll see this and offer input

Prime95 2019-03-29 02:12

You are well beyond Windows internals that I am familiar with.

My guess is that it may have something to do with being able to run prime95 as either a normal app or as a service (until Microsoft broke this cool feature several years ago).

The relevant code is:

[CODE]
GetStartupInfo (&sui);
if (sui.dwFlags == 0 || (sui.dwFlags & STARTF_USESHOWWINDOW)) {
return (WinMainCRTStartup ());
}
[/CODE]

If STARTF_USESHOWWINDOW is not set prime95 tries to run as a service.

Good luck!

sdbardwick 2019-03-29 03:33

I wonder if using the service version and putting [FONT="Courier New"]NET START[/FONT] and[FONT="Courier New"] NET STOP[/FONT] in batch files would work...

pokemonlover123 2019-03-29 09:45

[QUOTE=Prime95;512095]You are well beyond Windows internals that I am familiar with.

My guess is that it may have something to do with being able to run prime95 as either a normal app or as a service (until Microsoft broke this cool feature several years ago).

The relevant code is:

[CODE]
GetStartupInfo (&sui);
if (sui.dwFlags == 0 || (sui.dwFlags & STARTF_USESHOWWINDOW)) {
return (WinMainCRTStartup ());
}
[/CODE]

If STARTF_USESHOWWINDOW is not set prime95 tries to run as a service.

Good luck![/QUOTE]

I suppose that it might be that task scheduler doesnt pass STARTF_USESHOWWINDOW to the programs it runs! That may be causing prime95 to try to run as a service, causing the access violation. I've found a workaround for now, that doesnt require batch files. Have the task run cmd, then parameters are /C path/to/prine95

pokemonlover123 2019-03-29 13:18

What would happen if the flag STARTF_USESHOWWINDOWS wasn't set and the program still tried to run as a program rather than a service? Would building from source and changing that part to remove the check for that flag work? Or would another error occur from not being passed that flag?

pokemonlover123 2019-03-29 18:15

I found a really weird edge case XD

pokemonlover123 2019-04-01 21:00

I suppose there isn't anything new on this? I suspect the cause but still would like a fix :(. If there isn't one, so be it.

Prime95 2019-04-02 03:00

[QUOTE=pokemonlover123;512400]I suppose there isn't anything new on this? I suspect the cause but still would like a fix :(. If there isn't one, so be it.[/QUOTE]

Sorry, no fix planned.

pokemonlover123 2019-04-02 11:50

[QUOTE=Prime95;512417]Sorry, no fix planned.[/QUOTE]
Alright. I'll use the work around :)

pokemonlover123 2019-04-03 12:56

Thanks All
 
Thanks everyone for the help and investigation. I managed to find a workaround that simulates my desired behavior. Have a great day and have fun Prime95ing!

zeit 2019-10-01 08:55

It's too bad. I use task scheduler on computers of my job
Since there are Windows 10, the news computers do not work anymore for finding new Prime

Best regard


All times are UTC. The time now is 18:31.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.