You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by David Wortham <dj...@gmail.com> on 2006/11/17 00:39:26 UTC
Setting both Server and Directory Config Structs from the same config function
Hello fellow module developers!
I am trying to debug one of my directive-handling functions.
I want to set both the server and the appropriate directory structures when
the function is invoked.
Currently, I am getting Segmentation Faults (outside of all of my functions)
when I set my server configuration structure in my directive handling
function. I never seem to get the same problem with my directory struct
(only the server struct), and I do check for NULL structs when I use them.
As you know, the Segmentation Faults occur when the webserver is started up
(halting startup).
I have commented out this specific directive and the Segmentation Fault
never occurs without this particular directive. It seems to happen whether
I use the directive inside OR outside of a file/directory/location block in
the httpd.conf.
I believe the actual Seg Fault is occurring outside of my functions... I
have printfs to STDERR at the beginning and end of every function that
should run at startup. All of the functions that are opened close before the
Seg Fault error is shown.
Any ideas? The line count on the code is pretty large so pasting everything
is pretty much out of the question.
Thanks,
Dave
Re: Setting both Server and Directory Config Structs from the same config function
Posted by David Wortham <dj...@gmail.com>.
Nick (and other module developers),
I am still struggling with some Seg Faults.
They no longer occur from directory/file/location contexts.
Now, I have determined that it only occurs on one specific directive-handler
and only if the value of the flag is "On" (not "Off") and called from a
server/vhost context.
Detecting the context (server or directory) of a directive-handler call
seemed to fix half (the directory-context calls) of the Seg Fault
occurances.
Am I trying to write to a read-only struct? The part that stumps me about
that is there is another int in the same struct that is taking
directive-value changes just fine.
I have also noticed what seems to me to be an anomaly in my code:
When I create the server structs, I set a particular flag (an integer
member) to be 0. By the time the directive-handling call is made, the
value is something I have not set it to (usually around 135,xxx,xxx).
This only seems to happen in my SERVER config struct and for only ONE of its
members.
I have scoured my code for every possible place where I set this value and I
don't ever set it to be anything other than (0|1). I never use it as a
string or a pointer (from what I can tell).
The other values in the server config struct are set correctly, and this
particular value is set by the end of the create_server_config struct. I
know I am working with the correct server struct.
Any idea on what could be setting the server config struct variable?
Thanks,
Dave
Re: Setting both Server and Directory Config Structs from the same
config function
Posted by Nick Kew <ni...@webthing.com>.
On Thu, 16 Nov 2006 18:31:24 -0700
"David Wortham" <dj...@gmail.com> wrote:
> Nick,
> I was almost done copy-pasting and simplifying my code when I re-read
> your response.
>
> I had previously tried an if/else in the directive handling function
> (as in: if (dir->path is set) { set dir_struct; } else { set
> svr_struct; } ). For some reason, I didn't think that the call had to
> be mutually exclusive (only DIR or SVR, not both).
I don't think it does. But it's hard to see how/why you could
*usefully* set both in a single command handler.
> I read through the 2.0 code (thanks www.google.com/codesearch !),
> which has different comments than 1.3. In there, the path is what
> determines if the directive-handling function was called via a DIR or
> a SVR context (and I now realize they are mutually exclusive). A
> simple test to see if the cmd_parms->module_config is not NULL
> apparently is not sufficient.
There's an ap_check_command_context (or something like that -
this is from memory) that might help.
--
Nick Kew
Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/
Re: Setting both Server and Directory Config Structs from the same config function
Posted by David Wortham <dj...@gmail.com>.
Nick,
I was almost done copy-pasting and simplifying my code when I re-read your
response.
I had previously tried an if/else in the directive handling function (as in:
if (dir->path is set) { set dir_struct; } else { set svr_struct; } ).
For some reason, I didn't think that the call had to be mutually exclusive
(only DIR or SVR, not both).
I read through the 2.0 code (thanks www.google.com/codesearch !), which has
different comments than 1.3. In there, the path is what determines if the
directive-handling function was called via a DIR or a SVR context (and I now
realize they are mutually exclusive). A simple test to see if the
cmd_parms->module_config is not NULL apparently is not sufficient.
I am still testing some cases, but it looks like I was able to eliminate the
case that causes a Sef Fault.
Thx Nick!
Dave
On 11/16/06, Nick Kew <ni...@webthing.com> wrote:
>
> On Thu, 16 Nov 2006 16:39:26 -0700
> "David Wortham" <dj...@gmail.com> wrote:
>
> > Hello fellow module developers!
> > I am trying to debug one of my directive-handling functions.
>
> You haven't really told us enough to make a diagnosis.
>
> However, the thing that springs to mind from the above is that
> you might need to check your command's context. A simple first
> test for that would be to test whether there are some contexts
> where it works and others where it crashes.
>
> --
> Nick Kew
>
> Application Development with Apache - the Apache Modules Book
> http://www.apachetutor.org/
>
Re: Setting both Server and Directory Config Structs from the same
config function
Posted by Nick Kew <ni...@webthing.com>.
On Thu, 16 Nov 2006 16:39:26 -0700
"David Wortham" <dj...@gmail.com> wrote:
> Hello fellow module developers!
> I am trying to debug one of my directive-handling functions.
You haven't really told us enough to make a diagnosis.
However, the thing that springs to mind from the above is that
you might need to check your command's context. A simple first
test for that would be to test whether there are some contexts
where it works and others where it crashes.
--
Nick Kew
Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/