调试 fastcgi 应用程序
我在我的服务器上部署了一个 fastcgi 应用程序。当我尝试在服务器上运行它时,它崩溃了(稍后会详细介绍)。
首先是本地(开发)计算机上的一些事实:
- 该应用程序是 C/C++ 应用程序
- 我在 Ubuntu 10.0.4 LTS(服务器上的相同操作系统)上开发了该应用程序
- 在开发过程中,我使用 gdb 逐步执行代码来修复
- 我运行的 初始错误找到应用程序上的 ldd 并找到所有必需的共享库
- 我可以使用curl http://path/to/cgiapp
在我的本地计算机上测试并运行代码后,我构建了一个发行版本并打包它,使用 Netbeans 6.9 IDE
我将包安装在服务器并运行以下测试
首先在已安装的应用程序上运行 ldd,我注意到找不到某些文件。我通过将开发计算机上的文件复制到应用程序搜索它们的位置来修复此问题(也许不太理想) - 但是,当我再次运行 ldd 时,找到了所有库
然后我通过运行curl 测试了应用程序http://path/to/cgiapp 在控制台
出现的不是预期的消息,而是似乎是核心转储(即二进制流转储)的内容。
我的问题是:
- 任何人都可以解释为什么 ldd 正确指示所有文件(已加载?) - 但应用程序崩溃
- 应用程序在我的开发计算机上运行但无法在服务器上运行的最可能原因是什么?
- 由于应用程序在启动前崩溃,我不确定如何使用 gdb 来调试应用程序 - 显然,我会在尝试调试之前将调试版本复制到服务器。
上述第 3 点还有更复杂的情况。该服务器是一个精简、无头的服务器,因此它没有安装 gdb。
因此,即使我找到了一种调试应用程序的方法(在应用程序崩溃之前),我也不知道如何附加到远程进程。
任何关于如何开始深入了解这一点的想法将不胜感激。
I have deployed a fastcgi application on my server. When I try to run it on the server, it crashes (more of this later).
First some facts on the local (dev) machine:
- The application is C/C++ application
- I developed the app on Ubuntu 10.0.4 LTS (same OS on server)
- During development, I used gdb to step through code to fix initial bugs
- I run ldd on the app and all required shared libs are found
- I can test it on my local machine, using curl http://path/to/cgiapp
After getting the code tested and working on my local machine, I built a release version and packaged it, using Netbeans 6.9 IDE
I installed the package on the server and run the following tests
First run ldd on the installed app, I noticed that some files were not found. I fixed this by copying the files on the dev machine into the location that the app was searching for them (not ideal perhaps) - BUT, when I run ldd again, all libraries were found
I then tested the app by running curl http://path/to/cgiapp at the console
Instead of the expected message, there was what appeared to be a core dump (i.e. binary stream dump) onto the console.
My questions are:
- Can anyone explain why ldd indicates all files (loaded?) correctly - and yet app crashes
- What could be the most likely reason why the app runs on my dev machine but fails to run on the server?
- Since the app crashes before starting, I am not sure how to use gdb to debug the application - obviously, I will copy the debug version to the server before I attempt to debug.
There are further complication regarding point 3 above. The server is a lean and mean, headless server, so it does not have gdb installed.
So even if I found a way to debug the app (before it crashes), I don't know how I can attach to a remote process.
Any ideas on how to start getting to the bottom of this would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的问题是基于太多的误解。
出于同样的原因,某些应用程序运行 100 次没有任何问题,然后“随机”崩溃。
并非所有崩溃都与动态链接器有关,事实上大多数崩溃都与动态链接器无关。其他错误,例如堆损坏、缓冲区溢出、相差一错误等,是更常见的原因。
您没有提供足够的数据来回答该问题。
有什么症状?您是否查看过 apache 错误日志以获取线索?什么是崩溃堆栈跟踪?服务器上缺少哪些库并被复制过来?
您不需要复制调试二进制文件来调试它(它可能有帮助,也可能没有帮助,具体取决于崩溃实际发生的位置)。
Your question is based on way too many misunderstandings.
For the same reason some applications run 100s of times without any problems, then crash "randomly".
Not all crashes are related to the dynamic linker, in fact majority of crashes are not. Other bugs, such as heap corruption, buffer overflows, off-by-one errors, etc. etc. are much more frequent cause.
You have not supplied sufficient data to answer that question.
What are the symptoms? Have you looked at apache error log for clues? What is the crash stack trace? Which libraries were missing on the server and were copied over?
You don't need to copy debug binary to debug it (it may or may not help, depending on where the crash actually happens).
应原始发帖者的要求发布为答案:
1. 您可以将核心转储复制到带有 gdb 的计算机并在那里查看回溯。 gdb -c core_name binary.name,然后 bt。
2. 在启动之前你如何知道你的应用程序崩溃了?开始将内容记录到文件中,而不是仅依赖实时 gdb 会话。
Posting as an answer at original poster's request:
1. You can copy your core dump to a machine with gdb and see a backtrace there. gdb -c core_name binary.name, then bt.
2. How do you know your app crashes before starting? Start logging things to a file instead of relying on live gdb sessions only.