Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
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!
Posted
Updated 11-Apr-11 13:21pm
v2

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
 
Share this answer
 
In addition to Peters response, check global variables in your dll. Global object constructors are run before you enter the main function.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900