Ckan: [Bug] CKAN crashes with a C++ runtime error and BadImageFormatException trying to init CurlSharp

Created on 15 Jul 2020  ·  28Comments  ·  Source: KSP-CKAN/CKAN

Background

  • Operating System: Win10
  • CKAN Version: 1,28.0

  • KSP Version: 1.10.0

Have you made any manual changes to your GameData folder (i.e., not via CKAN)? No

Problem

Describe the bug
Error message pop ups in screen ask you to click ok, when you do so ask you to select ksp version after you do so ckan starts

Steps to reproduce

  • Go to... Ckan icon
  • Click on...ckan icon
  • See error

Expected behavior

  • ckan start

Screenshots (if applicable) atttached
Ckan error

CKAN error code (if applicable):none

Unhandled Exception: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
   at CurlSharp.NativeMethods.curl_global_init(Int32 flags)
   at CurlSharp.Curl.GlobalInit(CurlInitFlag flags)
   at CKAN.Curl.Init()
   at CKAN.CmdLine.MainClass.Main(String[] args)
Windows

Most helpful comment

The path reset trick alone didn't help (PC Windows 10), but ditching an old (probably out of date) copy of Anaconda [lots of path additions and lots of msvc*.dll] and an outdated java (that's probably unrelated, but once you've started cleaning things...) made it work.
Without the paths heads up, I wouldn't have considered the programming bits and bats as a thing, so thanks, and hope this "further things to consider" helps people.

All 28 comments

Do you have this problem with the pre-release?

https://github.com/KSP-CKAN/CKAN/releases/download/v1.28.0-PRE1/ckan.exe

I used ckan auto update function about 10 minutes ago

Rafael A. Acevedo
LTC(R), FA, AUS


From: HebaruSan notifications@github.com
Sent: Wednesday, July 15, 2020 3:44 PM
To: KSP-CKAN/CKAN CKAN@noreply.github.com
Cc: aggie88 rafi88@msn.com; Author author@noreply.github.com
Subject: Re: [KSP-CKAN/CKAN] [Bug] after update to dyson Ckan give a C++ runtime error "attempt to load c run library library incorrectly" (#3115)

Do you have this problem with the pre-release?

https://github.com/KSP-CKAN/CKAN/releases/download/v1.28.0-PRE1/ckan.exehttps://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKSP-CKAN%2FCKAN%2Freleases%2Fdownload%2Fv1.28.0-PRE1%2Fckan.exe&data=02%7C01%7C%7C9a80d1c924bc419c4eb908d828f78127%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637304390772563797&sdata=fNVBrgv%2FB9YTP8dfW21vBqFO8b0lXTepFQotQw%2FEt9c%3D&reserved=0


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKSP-CKAN%2FCKAN%2Fissues%2F3115%23issuecomment-658969971&data=02%7C01%7C%7C9a80d1c924bc419c4eb908d828f78127%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637304390772573792&sdata=sOHhUpdWCp0fMa%2BJfVYl8r2kwOb9AK1wDfoG%2BDVXcDA%3D&reserved=0, or unsubscribehttps://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAE4HDEQZOY5FOGHK6N3GMI3R3YBKHANCNFSM4O23SPOQ&data=02%7C01%7C%7C9a80d1c924bc419c4eb908d828f78127%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637304390772573792&sdata=sVteg3OrUHkI2DO4LlnBoQo%2BXlBG2TNW2eTR2mYjYWw%3D&reserved=0.

@aggie88 please answer the question, do you have this problem with the pre-release?

https://github.com/KSP-CKAN/CKAN/releases/download/v1.28.0-PRE1/ckan.exe

How do I know is the pre release?

[cid:[email protected]]

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10

From: HebaruSannotifications@github.com
Sent: Wednesday, July 15, 2020 3:46 PM
To: KSP-CKAN/CKANCKAN@noreply.github.com
Cc: aggie88rafi88@msn.com; Mentionmention@noreply.github.com
Subject: Re: [KSP-CKAN/CKAN] [Bug] after update to dyson Ckan give a C++ runtime error "attempt to load c run library library incorrectly" (#3115)

@aggie88https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Faggie88&data=02%7C01%7C%7Ce1cba959de374c0d49f608d828f7ce7b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637304392063427935&sdata=mCTUREzqgdWssEneaEBQkRnZvMGd9sQoQqov9hUS2Q0%3D&reserved=0 please answer the question, do you have this problem with the pre-release?

https://github.com/KSP-CKAN/CKAN/releases/download/v1.28.0-PRE1/ckan.exehttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKSP-CKAN%2FCKAN%2Freleases%2Fdownload%2Fv1.28.0-PRE1%2Fckan.exe&data=02%7C01%7C%7Ce1cba959de374c0d49f608d828f7ce7b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637304392063427935&sdata=zNWSxdclSk42WB3uVTLNQZC21qvZ5sYNbg7z4b7tX6o%3D&reserved=0


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKSP-CKAN%2FCKAN%2Fissues%2F3115%23issuecomment-658971114&data=02%7C01%7C%7Ce1cba959de374c0d49f608d828f7ce7b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637304392063427935&sdata=U94IiwWlmTd0gpQBc%2Fy0IK4yi%2BWPHXZRJqcva9EdMyA%3D&reserved=0, or unsubscribehttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAE4HDESPCYOC3CQRJACLOJTR3YBSLANCNFSM4O23SPOQ&data=02%7C01%7C%7Ce1cba959de374c0d49f608d828f7ce7b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637304392063437933&sdata=T5kqRMcPODvyArJKMIXs8PCgtoGFmwT%2FAO8nVWIZ728%3D&reserved=0.

[cid:[email protected]]

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10

From: HebaruSannotifications@github.com
Sent: Wednesday, July 15, 2020 3:46 PM
To: KSP-CKAN/CKANCKAN@noreply.github.com
Cc: aggie88rafi88@msn.com; Mentionmention@noreply.github.com
Subject: Re: [KSP-CKAN/CKAN] [Bug] after update to dyson Ckan give a C++ runtime error "attempt to load c run library library incorrectly" (#3115)

@aggie88https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Faggie88&data=02%7C01%7C%7Ce1cba959de374c0d49f608d828f7ce7b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637304392063427935&sdata=mCTUREzqgdWssEneaEBQkRnZvMGd9sQoQqov9hUS2Q0%3D&reserved=0 please answer the question, do you have this problem with the pre-release?

https://github.com/KSP-CKAN/CKAN/releases/download/v1.28.0-PRE1/ckan.exehttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKSP-CKAN%2FCKAN%2Freleases%2Fdownload%2Fv1.28.0-PRE1%2Fckan.exe&data=02%7C01%7C%7Ce1cba959de374c0d49f608d828f7ce7b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637304392063427935&sdata=zNWSxdclSk42WB3uVTLNQZC21qvZ5sYNbg7z4b7tX6o%3D&reserved=0


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKSP-CKAN%2FCKAN%2Fissues%2F3115%23issuecomment-658971114&data=02%7C01%7C%7Ce1cba959de374c0d49f608d828f7ce7b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637304392063427935&sdata=U94IiwWlmTd0gpQBc%2Fy0IK4yi%2BWPHXZRJqcva9EdMyA%3D&reserved=0, or unsubscribehttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAE4HDESPCYOC3CQRJACLOJTR3YBSLANCNFSM4O23SPOQ&data=02%7C01%7C%7Ce1cba959de374c0d49f608d828f7ce7b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637304392063437933&sdata=T5kqRMcPODvyArJKMIXs8PCgtoGFmwT%2FAO8nVWIZ728%3D&reserved=0.

How do I know is the pre release?

I linked to it twice. Once more:

https://github.com/KSP-CKAN/CKAN/releases/download/v1.28.0-PRE1/ckan.exe

No i do not have the problem with the pre-release

Rafael A. Acevedo
LTC(R), FA, AUS


From: HebaruSan notifications@github.com
Sent: Wednesday, July 15, 2020 3:54 PM
To: KSP-CKAN/CKAN CKAN@noreply.github.com
Cc: aggie88 rafi88@msn.com; Mention mention@noreply.github.com
Subject: Re: [KSP-CKAN/CKAN] [Bug] after update to dyson Ckan give a C++ runtime error "attempt to load c run library library incorrectly" (#3115)

How do I know is the pre release?

I linked to it twice. Once more:

https://github.com/KSP-CKAN/CKAN/releases/download/v1.28.0-PRE1/ckan.exehttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKSP-CKAN%2FCKAN%2Freleases%2Fdownload%2Fv1.28.0-PRE1%2Fckan.exe&data=02%7C01%7C%7C40bdcb5167d0401d515108d828f8ec00%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637304396853747010&sdata=x7uNnfz7g5EYisFI%2BWM2npYlKROG4Aq3Ay1daVkF8Wc%3D&reserved=0


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKSP-CKAN%2FCKAN%2Fissues%2F3115%23issuecomment-658975089&data=02%7C01%7C%7C40bdcb5167d0401d515108d828f8ec00%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637304396853756993&sdata=m60aivtTncz%2BKugqBbce9XbKTwTeDgodq9kLXG%2FY1mg%3D&reserved=0, or unsubscribehttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAE4HDEVZ43N6BOQX3FDXOETR3YCQHANCNFSM4O23SPOQ&data=02%7C01%7C%7C40bdcb5167d0401d515108d828f8ec00%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637304396853766976&sdata=EmqFZNKgeOEEhAKMqaHEb1vDY4xKHfvKpHDmqaQIe2w%3D&reserved=0.

I'm having this problem too!

The error message (showed in Command Prompt):

Unhandled Exception: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
   at CurlSharp.NativeMethods.curl_global_init(Int32 flags)
   at CurlSharp.Curl.GlobalInit(CurlInitFlag flags)
   at CKAN.Curl.Init()
   at CKAN.CmdLine.MainClass.Main(String[] args)

ckan.exe.11500.dmp.zip

The previous version (DRAKE - v1.28.0-PRE1) works well!

I'm using Windows 10 x64.

Thanks.

I am not experiencing this problem with 1.28.0

image

Just performed an update on Persistent Thrust with no issues.
image

(SideNote: I'm not bagging on y'all for having problems. Just providing another unrelated reference for the Devs,)

I'm having this exact same error. The pre-release works fine though.

Same issue here. It prompted for upgrade and after upgrading on launch it gives that error.
As if the build was done and it was not actually tested if it works 😐

However after building manually it was working fine, maybe something went wrong during build or uploading to download location.

However after building manually it was working fine, maybe something went wrong during build or uploading to download location.

It's not (exclusively, at least) a build error. As you can read in @7ranceaddic7's comment, it does work fine on some, maybe even most systems, including mine.

@HebaruSan found some information indicating that this is a issue caused by stray, duplicate msvc*.dll in PATH, which CurlSharp/curl loads during initialization:

Just the usual Windows DLL hell, so much about paid OSes and their "higher quality".

Likely not something CKAN can do anything about, except catch the exception, ignore it and make sure curl never gets called on broken systems (we only use it as fallback anyway).

However it's interesting that it works for you after you built it yourself. Did you change your environment in some way for this, like changing PATH, or installing Visual Studio, or other development tools/dependencies that might affect which DLL is loaded?

I edit my shortcut to ckan.exe to clear the PATH variable before executing it and works now!

C:\Windows\System32\cmd.exe /c "SET PATH= && START /D ^"C:\Program Files (x86)\CKAN" ckan.exe"

I tested trying to install some mod and it works...

Thanks

I just installed Visual Studio 2017 Community Edition. Had to modify cake build just a bit to get it to build because I apparently have multiple MSbuild systems installed and it was installing with some version that had issues building. Adding VSWhere to the mix helped it to find latest MSBuild version and use it to build correctly.

Odd is that it was able to run without problems after I built it, while the downloaded version had still issues. Path for both of them should be the same.

It might be due to the VSWhere and adding settings.ToolPath for the MSBuild parameters, but I doubt it has anything to do with it. While writing took another look at it and might even know where difference comes from. The ToolPath is directing to using x64 MSbuild. Not sure what is used for the downloaded version. If it is x86, then it might explain the path and dll-s loaded.

Edit:
That seems to be the case. In Task Manager downloaded version is shown as 32 bit and the one I built from sources is 64 bit.

Interesting, this setting is present in every project except Core, but only for Debug builds, not Release:

https://github.com/KSP-CKAN/CKAN/blob/ccc87fa9053008a055e3e4042c16e021a982c5a2/GUI/CKAN-GUI.csproj#L27

@krisavi, is that the setting you're changing?

Nope, I have not changed that one. The MSBuild I am using is x64, the one that is not working for me and seems outdated is 32 bit.

I tested again and found that the problem could be solved removing a file (libcurl.dll) from my PATH. But it is installed with Apache and I prefer to simply keep that change in the shortcut by clearing the PATH variable.

Yeah, from my testing I found libcurl.dll to be in path as well.
Found reason why my own built version worked and the differences there.
Dev team is aware of the findings already and I am sure they will get to the solution of it. May it be exception handling, running as 64bit where possible, dropping curl or some other solution they come up with.

The path reset trick alone didn't help (PC Windows 10), but ditching an old (probably out of date) copy of Anaconda [lots of path additions and lots of msvc*.dll] and an outdated java (that's probably unrelated, but once you've started cleaning things...) made it work.
Without the paths heads up, I wouldn't have considered the programming bits and bats as a thing, so thanks, and hope this "further things to consider" helps people.

The path reset trick alone didn't help (PC Windows 10), but ditching an old (probably out of date) copy of Anaconda [lots of path additions and lots of msvc*.dll] and an outdated java (that's probably unrelated, but once you've started cleaning things...) made it work.

Same story. After I uninstalled Anaconda, CKAN works normally again. Had the same issue initially

I can confirm that uninstalling Anaconda fixed this issue for me.

I don't even know what Anaconda is and have nothing with this name on my PC, but after auto-updating, I get

Unbehandelte Ausnahme: System.BadImageFormatException: Es wurde versucht, eine Datei mit einem falschen Format zu laden.
 (Ausnahme von HRESULT: 0x8007000B)                                                                                        
    bei CurlSharp.NativeMethods.curl_global_init(Int32 flags)                                                               
    bei CurlSharp.Curl.GlobalInit(CurlInitFlag flags)                                                                      
    bei CKAN.Curl.Init()                                                                                                    
    bei CKAN.CmdLine.MainClass.Main(String[] args)

I downgraded to Drake for now, which works fine.

I can confirm that uninstalling Anaconda fixed this issue for me.

Same here, thank you!

Same BadImageFormatException with Curl.Init using CKAN v1.28.0 Dyson.
Removing Anaconda from system path worked for me.

Is there a workaround without removing anaconda? I actually need to use Anaconda for other purposes on my PC.

Same problem. Removing anaconda does not seem to be a good solution.

It seems they need to ship new version soon with the code changes. Forcing users to remove anaconda and other tools they might use for development is not a good idea of course.

Is there a workaround without removing anaconda? I actually need to use Anaconda for other purposes on my PC.

From what I tested, then building the app on your own seems to work and also the "prefer 64bit" options while building seemed to be quite ok as well. I am using on my machine the version I built myself, because had libcurl.dll in one of the folders in path. Removing or renaming the file or removing the path helped as well, but stopped the app to not work that shipped it. So for me the self-built version seemed not to have such problems.
As temporary workaround something like C:\Windows\System32\cmd.exe /c "SET PATH= && START /D ^"C:\Program Files (x86)\CKAN" ckan.exe" seemed to have worked for some people.
You might only need to remove it from PATH variable, but not from machine fully. I am not sure if anaconda needs itself to be in the PATH or not in order to work. It might not need it, but is putting itself there for ease of use, so you could type in anaconda.exe in any folder in cmd to run it and not to address it by relative or absolute path.

One more way to have working CKAN is to use previous release "Drake" and not update until the fix is released.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DasSkelett picture DasSkelett  ·  4Comments

btbonval picture btbonval  ·  6Comments

davidgiven picture davidgiven  ·  6Comments

DasSkelett picture DasSkelett  ·  6Comments

w1wwwwww picture w1wwwwww  ·  6Comments