用CPP编写CGI [英] Writing CGI's in CPP

查看:73
本文介绍了用CPP编写CGI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在用CPP编写许多CGI,并且其中之一正在碰壁.我可以在标准调试器上对其进行测试,然后在main()处设置一个断点.这可以正常工作,并且可以解决问题.当我将其安装在本地主机Apache Server cgi-bin目录中时,它会在到达main()入口点之前退出.
产生了通常的错误日志"和响应"页面,(配置错误),(标题的结尾过早)这是按预期的,它的距离还远远不够,无法产生任何输出.

一个人怎么进攻呢?

顺便说一句,我的调试技术是将ASSERT(0)放到我想中断的位置.它允许我附加调试器,并逐步执行代码. main()的ASSERT(0)第一行在此CGI上没有得到期望的结果. (已工作且仍在工作)在其他所有服务器上.
这使我感到怀疑,要么int3的中断向量未正确设置,要么从未到达main().我很难相信前者.该向量是在创建执行环境时在CreateProcess()的早期阶段设置的,即,在与我的流程特别相关的任何事情发生很久之前.

我还将ASSERT(0)放入应用程序构造函数中.永不开火!

作为附带说明,我的main()埋在DLL的深处.它调用MyCgiApp :: CgiMain(),这是入口点
这可能不常见,但是可以在几十个CGI中使用.

拔头发,

谢谢您的帮助:)

它变得有趣了.从HTML表单调用它,它会命中main(),(现在可以了,它没有更早完成,我什么都没改变),如果我将ASSERT保留在那里.使用断言,它将打印页面,如果没有断言,它将失败!

Hi,

I am writing a number of CGI''s in CPP, and I am running into a Brick Wall with one of them. I can test run it under the Standard Debugger, and set a Breakpoint at main(). This works fine, and it gets there No Problem. When I install it in the Local Host Apache Server cgi-bin dir, it bails out BEFORE it hits the main() entry point.
The Usual Error Log, and response page are produced, (Misconfiguration),(Premature End of Header) Which is as expected, it never got far enough to produce any output.

How does one Attack this.

BTW My Debug tecnique is to put an ASSERT(0) where I want to break. It allows me to attach the Debugger, and step tru the Code. An ASSERT(0) first line of main() does not give the desired result on this CGI. (Worked and Still Works) on All Others.
It makes me surmise that either the Interrupt vector for int3 is not set up correctly, or, that main() is never reached. The Former I would find hard to believe. That vector is set in the early stages of CreateProcess()when the execution environment is created, i.e. Long before anything in particular relating to my process takes place.

I also put an ASSERT(0) in the App Constructor. Never Fires!

As a Side Note, my main() is burried deep inside a DLL. It calls MyCgiApp::CgiMain(), which is the entry point
This may be unusual, but, works in Several dozens of CGI''s.

Pulling my Hair Out,

Thanks for Any Help at All :)

It gets Funnier. Called it from a HTML Form, and it Hits main(), (Now it does, It Didn''t do so earlier, I changed Nothing) if I keep the ASSERT There. With the Assert it prints the Page, without the Assert, it Fails! Why is all this so Thin and Fragile!

推荐答案

这一切为何如此之细而脆弱呢?它具有强烈的已损坏或未初始化内存的香气.在调用CgiMain之前,请仔细查看您的DLL的功能. (这可能涉及DLL初始化代码中的一些误解……)传递给cgi的参数(命令行以及CgiMain调用中的parms)也可能需要调查.

从这个距离开始,很难再做任何事情了,但希望这些想法能给您一个领先的机会.

干杯,
Peter
This has a strong aroma of corrupted or uninitialised memory. Have a close look at what your DLL does before it calls CgiMain. (This may involve a bit of spelunking in DLL initialisation code...) The arguments passed to the cgi (command line, as well as parms in the CgiMain call) may also bear investigation.

Pretty hard to do any more form this distance, but hopefully these ideas will give you a head start.

Cheers,
Peter


除了Peters响应外,还要检查dll中的全局变量.在输入主函数之前,将运行全局对象构造函数.
In addition to Peters response, check global variables in your dll. Global object constructors are run before you enter the main function.


这篇关于用CPP编写CGI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆