i get smilar error when i try launch my application (c++ command line) from xcode , (the application work fine from terminal .
XCode: Could not launch "APP_X_Y" - 'A' packet returned an error: -1
i tried every mentioned solution in above question but none of them helped me.
i finally found problem is launching using LLDB so GDB works fine. but i want to debug my program using LLDB and launch with default config in xcode.
the error is in following lldb function:
Error
PlatformRemoteGDBServer::LaunchProcess (ProcessLaunchInfo &launch_info)
{
Error error;
lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
m_gdb_client.SetSTDIN ("/dev/null");
m_gdb_client.SetSTDOUT ("/dev/null");
m_gdb_client.SetSTDERR ("/dev/null");
m_gdb_client.SetDisableASLR (launch_info.GetFlags().Test (eLaunchFlagDisableASLR));
const char *working_dir = launch_info.GetWorkingDirectory();
if (working_dir && working_dir[0])
{
m_gdb_client.SetWorkingDir (working_dir);
}
// Send the environment and the program + arguments after we connect
const char **argv = launch_info.GetArguments().GetConstArgumentVector();
const char **envp = launch_info.GetEnvironmentEntries().GetConstArgumentVector();
if (envp)
{
const char *env_entry;
for (int i=0; (env_entry = envp[i]); ++i)
{
if (m_gdb_client.SendEnvironmentPacket(env_entry) != 0)
break;
}
}
const uint32_t old_packet_timeout = m_gdb_client.SetPacketTimeout (5);
int arg_packet_err = m_gdb_client.SendArgumentsPacket (argv);
m_gdb_client.SetPacketTimeout (old_packet_timeout);
if (arg_packet_err == 0)
{
std::string error_str;
if (m_gdb_client.GetLaunchSuccess (error_str))
{
pid = m_gdb_client.GetCurrentProcessID ();
if (pid != LLDB_INVALID_PROCESS_ID)
launch_info.SetProcessID (pid);
}
else
{
error.SetErrorString (error_str.c_str());
}
}
else
{
**error.SetErrorStringWithFormat("**'A' packet returned an error: %i",** arg_packet_err);**
}
return error;
}
as you can see 'a' packet error is in lldb now question is how can fix this problem ? is there any solution to reinstall / reconfigure LLDB in xcode? can anyone find where is problem from lldb function.
i'm using latest Mac OS + Xcode 4.6.3 latest
please share your ideas .
This error happens when debugserver cannot launch the app you are trying to debug. debugserver launches, attaches, stops, inspects and controls the process - it is a small program with all of these responsibilities. It communicates to lldb (possibly inside Xcode) via the "gdb remote protocol", with some minor extensions.
If you've built your own lldb, chances are that debugserver is not properly code signed so it cannot launch apps.
If you've changed your /etc/hosts file, check that you have a line like 127.0.0.1 localhost in there. Some people have modified their /etc/hosts (I have no idea why) and removed this line, and this has caused problems for lldb trying to communicate with debugserver.
Otherwise, check the output in Console.app to see if there are any useful messages logged.
I was in the same situation. It happened after updating to Xcode 5 in my case.
After all it works fine now.
I followed the command line executions as per the comment from Jason Molenda.
When running "xcrun lldb ..." I got an error:
xcrun error failed to exec real xcrun. (no such file or directory)
After Googling, I figured this out:
xcode-select -print-path
/Developer
As my Xcode was not in there, I did:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
I don't know why, but it didn't work immediately in my case. After quitting Xcode, Terminal, etc., Xcode ran and debug worked as expected.
Related
I know there were already some similar questions and it seems the question is not arose by OpenCV but by MacOS authority rule.
I have read some solutions, like create a Info.plist into source directory. And that works! But for me now only in Debug mode in QTCreator, not in Release mode. That is, when I run the program in Debug mode, everything is just OK. But in Release mode within QTCreator, the error message shows up:
OpenCV: not authorized to capture video (status 0), requesting...
16:12:22: The program has unexpectedly finished.
Some more strange informations. The program, say Test.app which is generated by QTCreator in Release or Debug mode, can be executed by directly double clicking on it or on the executable file residing in Test.app/Contents, after authorized for sure.
Additional System Information:
macOS Catalina Version 10.15.4
Qt 5.14.2
OpenCV 4.3.0
Also the Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>NSCameraUsageDescription</key>
<string>uses camera to see vision targets</string>
</dict>
</plist>
Some codes may be helpful. FYI, the program crashes before the Camera class created.
// camera.cpp
std::shared_ptr<Camera> Camera::Ptr = nullptr;
void Camera::CreateCamera()
{
if(!Ptr)
Ptr.reset(new Camera);
}
Camera::Camera()
: _device(1)
{
}
bool Camera::GrabMerged(cv::Mat &img)
{
if(_device.isOpened())
{
cv::Mat tmp;
_device.read(tmp);
if(tmp.empty())
{
qWarning("[Camera] Grab image failed.");
return false;
}
qInfo("[Camera] merged image info: cols=%d, rows=%d, channels=%d, step0=%lu,step1=%lu, type=%d",
tmp.cols, tmp.rows, tmp.channels(), tmp.step[0], tmp.step[1], tmp.type());
cv::cvtColor(tmp, img, cv::COLOR_RGB2BGR);
return true;
}
qCritical("[Camera] Camera is not opened.");
return false;
}
...
// camera.h
class Camera: public QObject
{
...
private:
cv::VideoCapture _device;
...
}
In case helpful for others.
Qt Creator > Projects > Run > Environment > add OPENCV_AVFOUNDATION_SKIP_AUTH 0 , then you will get the MacOS prompt "QtCreator wants to access the camera". I'm running macOS 11.4
Thanks for taking time to push a minimal project that allow to reproduce the error.
After some test, it appears that this project works fine when started from command line or by double-clicking on the app bundle icon (both in Release and Debug mode). In the later case, system ask for permission to use the camera when clinking on the open button. Once permission is granted, we need to click again on the button, this is an expected behavior with OpenCV VideoCapture on macos.
But when I start it from Qt Creator, I had this weird message :
dyld: Symbol not found: __cg_jpeg_resync_to_restart
Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /usr/local/lib/libJPEG.dylib
in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
18:29:38: The program has unexpectedly finished.
This is not the same as yours but that shows that there is some difference between normal execution and execution from QtCreator.
And in my case, Qt Creator is the culprit.
And after disabling the DYLD_LIBRARY_PATH variable under the Run environment (Projects Settings -> Run -> Environment), it works fine from QtCreator. Hourah !
My settings looks like :
This is with Qt Creator 4.12 / Qt 5.14.2 / OpenCV 4.3.0
Attempting to debug an NPAPI plugin by attaching to the plugin process does not appear to work in 10.11.
Attaching with lldb reveals:
sudo lldb -p 39337
(lldb) process attach --pid 39337
error: attach failed: unable to attach
This seems to affect both 'legacy' webkit used for embedded Webkit (with plugin host named WebKitPluginHost) and 'modern' webkit used in safari (with plugin host named com.apple.WebKit.Plugin.64)
I have disabled the "Debugging Restrictions" using csrutil in recovery mode, but that does not appear to help in this case.
I haven't tried it specifically in 10.11, but I find the easiest way is to add a blocking section to wait for your plugin to be debugged in the startup code:
#if WAIT_FOR_DEBUGGER
static bool beingDebugged() {
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()}; size_t mib_size = 4;
struct kinfo_proc kp; size_t kp_size = sizeof(kp);
int result = sysctl(mib, mib_size, &kp, &kp_size, NULL, 0);
return (0 == result) ? (P_TRACED & kp.kp_proc.p_flag) : false;
}
#endif
then in startup code somewhere:
#if WAIT_FOR_DEBUGGER
#warning "WILL BLOCK ON P_TRACED"
while (!beingDebugged())
sleep(1);
#endif
If you have trouble finding the right process to connect to you could have this also output the PID to a file so you can read and find it.
Problem
I have some half-year old c-programs I was working on and had hoped that I could continue working on them now. I did installed windows 10 (64-bit) right after that, so I thought could be a problem but the programs have run on windows 10 since then.
About 2 months ago, I could build with the make-file and run the executables but when I tried again today, it seems to me like the executables are not running. I have now also tried updating cygwin and (I think) all relevant packages.
I have googled if there are any important changes to cygwin but I didn't really find anything.
Details
When I try running any program nothing happens for a long while at the ./executeables/helloworld.exe line and then eventually producing the error:
$ make 1
gcc 1-helloworld.c -o ./executeables/helloworld.exe -lncurses
./executeables/helloworld.exe
0 [sig] make 7332 get_proc_lock: Couldn't acquire sync_proc_subproc for(5, 1), last 7, Win32 error 0
1324 [sig] make 7332 proc_subproc: couldn't get proc lock. what 5, val 1
After this, nothing happens and I cannot even stop the process with ctrl+C so I have to end "make.exe" (which oddly enough consists of 2 processes) with task manager. The terminal then says nothing more than
makefile:2: recipe for target '1' failed
make: *** [1] Error 1
So I'm guessing there is a problem with getting a mutex or a lock from windows for creating a process, but I have no clue why this would happen.
Code
The example in this try uses this code for a hello world program, but it's the same for the more complex programs as well.
#include <ncurses.h>
#include <string.h>
int main() {
char *message="Hello World";
int row,col;
int len = strlen(message);
initscr();
getmaxyx(stdscr, row, col); //screensize
mvprintw(row/2, (col-len)/2, "%s", message); //center of screen
getch();
refresh();
endwin();
return 0;
}
Have anyone seen this problem before?
Avast antivirus was preventing the program from running correctly. Disabling it made everything run perfectly. I finally found the answer in this thread:
Netbeans 8.1 IDE compiles and builds C programs but does not show their output
note:
Since it is not marked as an answer to the question in that thread and because that question is not explicitly focusing the same error (although presents the same error), I will keep my question instead of marking it as a duplicate.
Thank you, Sheshadri Iyengar for providing the solution.
I’m using Xcode 4.6.3 to build a library for OS X. My project includes a target called LibraryTest, which is a command-line app to test the functionality of the library. Both the library and the test app build fine, but when I try to run the app it quits immediately and the debug console shows:
error: failed to launch '/Users/bdesham/Library/Developer/Xcode/DerivedData/Wavelength_and_Spectrum_Library-byosniusyaoidgdcpzwzuzkitzgv/Build/Products/Debug/LibraryTest'
-- error: Host::LaunchProcess (launch_info) => pid=0,
path='/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver'
err = error: ::posix_spawnp (
pid => 98649,
path = '/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver',
file_actions = 0x10b09e268,
attr = 0x10b09e2a0,
argv = 0x7fe2701377e0,
envp = 0x0 )
err = Bad file descriptor (0x00000009) (0x00000009)
error: failed to launch '/Users/bdesham/Library/Developer/Xcode/DerivedData/Wavelength_and_Spectrum_Library-byosniusyaoidgdcpzwzuzkitzgv/Build/Products/Debug/LibraryTest'
-- error: Host::LaunchProcess (launch_info) => pid=0,
path='/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver'
err = error: ::posix_spawnp (
pid => 98649,
path = '/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver',
file_actions = 0x10b09e268,
attr = 0x10b09e2a0,
argv = 0x7fe2701377e0,
envp = 0x0 )
err = Bad file descriptor (0x00000009) (0x00000009)
(Line breaks added for readability.) I have the Xcode 5 DP installed, so I tried removing Xcode 4 and reinstalling it from the Mac App Store, but no dice. Deleting DerivedData didn’t help either. Any ideas?
Restarting my Mac seems to have fixed this.
Check "Build Settings" -> "Provisioning Profile". It should be "none" or some provisioning for Max OSX (if you're building for the app-store) . In my case it erroneously had "iOS Ad Hoc Provisioning Profile". This resolved this problem for me.
Note: I found this out by checking the syslog ("cat -f /var/log/system.log" in terminal, then start app). It wrote a crash report which had "...embedded provisioning profile not valid:..." among other lines. Checking the app container itself indeed showed an "embedded.provisionprofile" file, which triggered me to check the build settings for it.
I solved it by updating iOS. I was using JailBreak iOS version.
My project at work debugged under 10.6/Xcode 3.2.5 works fine but at home the same project run under Lion/Xcode 3.2.5 tosses dozens of these
unable to read unknown load command 0x26
messages in the debugger. Any ideas on what I can do to determine what GDB is complaining about? It still "seems" to work, but I have no idea what might be missing or wrong.
Note this is a regular OSX app, not iOS.
The message comes from bfd/mach-o.c:
switch (command->type)
{
case BFD_MACH_O_LC_SEGMENT:
if (bfd_mach_o_scan_read_segment_32 (abfd, command) != 0)
return -1;
break;
.....
default:
fprintf (stderr, "unable to read unknown load command 0x%lx\n",
(unsigned long) command->type);
break;
}
The warning says that BFD cannot recognize the Mach-O section load command it has encountered.
Looking at bfd/mach-o.h where known load commands are described, we find that commands there range from 0x1 to 0x18, yet nothing beyond.
Mac OS X (Lion) defines load constants in /usr/include/mach-o/loader.h (available if you've installed XCode), from 0x1 to 0x27. Therefore, the most logical explanation to seeing the warnings for load commands > 0x18 appears to be the lack of the said codes in BFD's own header.
Also, for follow-ups consider looking at: https://bugs.launchpad.net/tarantool/+bug/1018356