gdb fails with error 193 when debugging MinGW-compiled code - c

This is shown when I try to debug my code with Eclipse:
I then tried creating a simple Hello World program manually with Notepad++ and the command-line gcc. When I launched the gdb debugger this happened:
(gdb) run
Starting program:
C:\Documents and
Settings\Pieter\Bureaublad/test.exe
Error creating process C:\Documents
and
Settings\Pieter\Bureaublad/test.exe,
(error 193).
The binary runs fine, but as soon as I try to debug it error 193 is returned. I'm working with C code that is processed by the MinGW GCC compiler. I tried reinstalling both the compiler and the debugger (latest versions) but that didn't change anything. It has worked in the past, and I do not remember making any changes to settings related to the compiler.
Here's an example of an error log as it was generated by Eclipse.
!ENTRY org.eclipse.cdt.dsf.gdb 4 5012
2010-02-09 18:19:47.375 !MESSAGE Error
in final launch sequence !STACK 1
org.eclipse.core.runtime.CoreException:
Failed to execute MI command:
-exec-run Error message from debugger back end: Error creating process
C:/Documents and Settings/Pieter/Mijn
documenten/My
Dropbox/Unief/C/H12/Opdr07/Debug/CH12O07.exe,
(error 193). at
org.eclipse.cdt.dsf.concurrent.Sequence.abortExecution(Sequence.java:560)
at
org.eclipse.cdt.dsf.concurrent.Sequence.access$4(Sequence.java:552)
at
org.eclipse.cdt.dsf.concurrent.Sequence$2.handleErrorOrWarning(Sequence.java:424)
at
org.eclipse.cdt.dsf.concurrent.RequestMonitor.handleFailure(RequestMonitor.java:314)
at
org.eclipse.cdt.dsf.concurrent.RequestMonitor.handleCompleted(RequestMonitor.java:277)
at
org.eclipse.cdt.dsf.concurrent.RequestMonitor$2.run(RequestMonitor.java:239)
at
java.util.concurrent.Executors$RunnableAdapter.call(Unknown
Source) at
java.util.concurrent.FutureTask$Sync.innerRun(Unknown
Source) at
java.util.concurrent.FutureTask.run(Unknown
Source) at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown
Source) at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown
Source) at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source) at
java.lang.Thread.run(Unknown Source)
!SUBENTRY 1 org.eclipse.cdt.dsf.gdb 4
10004 2010-02-09 18:19:47.546 !MESSAGE
Failed to execute MI command:
-exec-run Error message from debugger back end: Error creating process
C:/Documents and Settings/Pieter/Mijn
documenten/My
Dropbox/Unief/C/H12/Opdr07/Debug/CH12O07.exe,
(error 193).

Could it be that either you are using an older version of gdb, that doesn't support native MinGW debugging (unlikely since you said you updated to the latest version), or you are invoking the debugger incorrectly? In other words, if your executable is named helloworld.exe, gdb helloworld may give you that error, whereas gdb helloworld.exe may work.
Edit: further googling says that trying a directory name without spaces might work (the solution is for Code::Blocks, but it doesn't hurt to try).

Google tells me that "Error 193" is a Windows error code that means an executable is not, in fact, executable. Looks like there's something wrong with your EXE - can you start it directly?

your shared library setting got turned on (probably because you switched your project from an executable to a shared library, then back) and gcc is still being called with the '-shared' options, but the output file has the .exe extension. There is a checkbox called 'shared' in
Properties => C/C++ Build => Settings => Tool Settings => MinGW C Linker => Shared Library Settings.
Make sure it's not checked. I had also error 193 until I flipped this off.

This thread does mention:
Error 193 is ERROR_BAD_EXE_FORMAT
this can be an issue with your cygwin installation.
Note (as an example of "problem with cygwin installation): there was a bug with gdb if installed in a cygwin referenced with a path including a space in it (see this thread)
What version of gdb are you using when you reproduce the issue outside of Eclipse CDT?

You said:
(gdb) run
Starting program: C:\Documents and
Settings\Pieter\Bureaublad/test.exe
Error creating process C:\Documents
and
Settings\Pieter\Bureaublad/test.exe,
(error 193).
Might it have anything to do with the forward/reverse slash at the end of the executable path? Perhaps the part Bureaublad/test.exe is here intended as a single executable, and it can't be found?

Related

Can't launch debug - C in VS code on Linux

Let me preface this, I am very new to linux and to working on a non-IDE based setup.
I am trying to debug a very simple C program using vs code version 1.55
I unloaded all modules beforehand, so vs code can load appropriate default gcc & gdb versions (which it did, GCC 8.2)
I am following the VS code getting started documentation for setting up and everything seems very straight forward until I try to debug.
I use the default settings as instructed, the file builds successfully but then I get the below
/usr/bin/gdb: symbol lookup error: /usr/bin/gdb: undefined symbol: PyUnicodeUCS4_FromEncodedObject
please note that I cannot rebuild python with ucs4 enabled as suggested in another thread as I have no root access. however I can change VS code version to an earlier one if this will help.
Thanks.
I think this issue is specific to my environment but I will post the answer anyway as it may face someone else.
So this for me was 2 separate issues:
First gdb doesn't start and second vs code can't start gdb.
To check if this is the case try to launch gdb from terminal (not vs code) by typing gdb in the terminal (after loading gdb if needed), I was receiving the error above
Solution to this part is this as T0maas thankfully suggested above
Steps for linux newbies:
ldd gdb (or /usr/bin/gdb) (with vs_code loaded)
from step one get the python library path
unload all modules
load gdb
LD_PRELOAD=<python path from 1>
bash -c "export LD_PRELOAD"
load vs_code
load gdb
After the above steps writing gdb in the terminal should start gdb
Part 2:
The rest of the problem was when I tried to launch debugging session through the GUI of vs_code (still produced the same error)
In the terminal (after loading gdb) type whereis gdb
For me this produced multiple directories the first of which was /usr/bin/gdb (this is the default used in vs_code launch.json)
Changing that directory in the launch.json file to a different one of the other directories solved the second part of the problem for me.

Error when executing C program using PostGreSQL libpq in Windows 10. (libssl-1_1-x64.dll and non-existent Avast antivirus)

I have a C program (compiled and built in VisualStudio 2019), which I want to connect to a PostGreSQL DB. I included the libpq header files, put the DLLs in the right place, etc. Compilation and build operations finish with no errors.
However, when I try to execute this function, I got an error.
int pgTest() {
int libpq_ver = PQlibVersion();
printf("%i\n", libpq_ver);
return EXIT_SUCCESS;
}
In debugging mode, I can see this error in the debugging console:
C:\Users\JohnDoe\Documents\foo.exe (process 21388) exited with code -1072365566.
Activation context generation failed for "C:\WINDOWS\SYSTEM32\libssl-1_1-x64.dll". Dependent Assembly
I have also checked out the EventViewer and surprisingly I found a weird error related to Avast antivirus. which I never had installed in my PC:
Activation context generation failed for "C:\WINDOWS\SYSTEM32\libssl-1_1-x64.dll". Dependent Assembly Avast.VC140.CRT,processorArchitecture="amd64",publicKeyToken="fcc99ee6193ebbca",type="win32",version="14.0.23918.0" could not be found. Please use sxstrace.exe for detailed diagnosis.
Sorry if the error looks confusing, that's why I'm asking you, because I can't imagine what libssl-1_1-x64.dll has to do with Avast, taking into account that I never had this antivirus installed, or even tried in my PC.
I'd appreciate any ideas or help.
Thanks in advance
It looks like a side effect of a wrong installation of OpenSSL.
I re-installed OpenSSL from scratch and the error dissapeared.

Eclipse - "Launching 'KeyInPlaintext' Debug has encountered a problem. Error starting process."

I am currently attempting to compile and run a C program in eclipse. The problem is, every time I attempt to run a program, the same error shows up.
The image shows the error that is displayed. I am not sure what to get out of that error.
I currently have cygwin installed, and am able to run gcc and g++ on the command prompt. I also have PE Windows Parser and Cygwin PE parser enabled under Binary Parsers. I have also cleaned and built the project many times over.

Running .exe in cygwin opens windows console with MapViewOfFileEx error, how do I fix this?

I'm trying to run programs I've compiled with GCC. When I run them through cygwin, a windows terminal opens for a couple of miliseconds (or so) giving off the error:
fatal error - MapViewOfFileEx shared 5'(0x66). win32 error 6. Terminating
It's followed by a stack trace. (this was the best shot, had to use video camera)
It doesn't seem to affect the programs but since it's a "fatal error" I suppose it would be good to fix. I tried googling the error, and found that multiple cygwin1.dll in the path shown when running the command
cygcheck -s
could be the cause, but I only found 1 cygwin1.dll.
The problem could have come from when I tried to open a cygwin-created executeable in windows and I read that I should copy the cygwin1.dll into my windows-folder but I simply deleted it after realizing that I needed several more files (libraries).

Error while loading shared libraries - Using CUnit on Netbeans

I am a newbie working with Cygwin and CUnit. I have to develop some Unit Tests using CUnit and Netbeans and I have followed the next tutorial:
https://netbeans.org/kb/docs/cnd/c-unit-test.html?print=yes#project
At the end, when I was trying to run the first example test I got stocked by an error:
0 [main] make 4380 C:\cygwin\bin\make.exe: *** fatal error - error while loading shared libraries: /cygdrive/C/Program Files/NetBeans 8.0.2/ide/bin/nativeexecution/Windows-x86_64/unbuffer.dll: cannot open shared object file: Exec format error
448 [main] make 4380 open_stackdumpfile: Dumping stack trace to make.exe.stackdump
I don't know if this has relation to the Cygwin version I have, I have a computer running Windows 7 Enterprise 64bits edition. I have configured my C project to use Cygwin 64bits edition...
Could you please share any idea about how I can solve this?
Thanks!
I had a similar issue, but in my case I was trying to run CppUnit tests in Netbeans. I was using make provided by MSYS2 and it was failing to load unbuffer.dll, but error was "No such file or directory". I switched the make from MSYS2 for the one found in MSYS and the error went away. You could try this as a workaround.
I found sole here:
https://bz.apache.org/netbeans/attachment.cgi?id=164026&action=edit
Need download new version of unbuffer.dll.
Yar

Resources