in reply to Re: DB open segfault
in thread DB open segfault

Hi,
first of all, thanks for your quick answer.
Talking about the issue, the permissions are right because the cgi works until a "dbmopen,dbmclose,tie,untie" is reached.

I have many cgi scripts with html embedded, and when I request a cgi with any of the functions mentioned above, the result it's shown partially in the browser:
use CgiLib; use ScmConf; use ScmLib; use LWP::Simple; use AnyDBM_File; &ScmConf::Init(); $starting_time = time; &PrintHead(*STDOUT,"Document Index", ""); &ReadParse() || &PrintErrorMessage("Error in parameter list"); $key = $input{"key"}; $key =~ s/\s*$//; ($search_string = $key) =~ s/-/ /g; $selected_category = $input{"category"}; @selected_status = split(",", $input{"status"}); if ($key =~ /^\w\w\w ?\d\d\d\d\d[ \w]*$/) { print "<br><strong>Note</strong>: Search time can be greatly improve +d if a document number is specified using dashes '-' between prefix, +regnumber, variant and doctype<br><br>\n"; } print "<table style=\"border: 1px solid #666666; margin-left: 20px; ma +rgin-right: 20px;\" cellpadding=\"2\" cellspacing=\"4\">\n"; print " <tr>\n"; print " <th class=\"colheader\">Number<br><nobr>[Document Info]</no +br></th>\n"; print " <th class=\"colheader\">Title<br>[Document]</th>\n"; print " <th class=\"colheader\">Author</th>\n"; print " <th class=\"colheader\">Status</th>\n"; print " <th class=\"colheader\">Last Updated</th>\n"; print " </tr>\n"; &flush(); my $count = 0; my $count2 = 0; my @result; tie(%DOC, 'AnyDBM_File', &documentdb, O_RDONLY, 0664);

And at this point it fails and shows the following message in the "error_log" file:
child pid 29271 exit signal Segmentation fault (11), possible coredump in /export/home


But, in the other hand, when I request a cgi without any of this functions, it is shown correctly.

Also, I have trying to execute a simply perl outside of the server, in command line:
my $db = shift(@ARGV); my $file = shift (@ARGV); my (%DOC); open (SAL, ">$file"); dbmopen (%DOC, $db, 0666); foreach $keys (%DOC) {@a = split ('\0', $DOC{$keys}); $q = join ('-',@a); print SAL $keys ."=".$q."\n";} dbmclose (%DOC); close (SAL); exit 0;
and it generates the error: Segmentation fault (core dumped)

And for all of this, I'm a little bit confused about what could I do to solve this.
Thanks again for your help

Replies are listed 'Best First'.
Re^3: DB open segfault
by alexm (Chaplain) on Jan 09, 2008 at 17:15 UTC
    foreach $keys (%DOC) {@a = split ('\0', $DOC{$keys}); $q = join ('-',@a); print SAL $keys ."=".$q."\n";}
    You probably meant (I'm also reformatting the code):
    foreach $key (keys %DOC) { @a = split ('\0', $DOC{$key}); $q = join ('-', @a); print SAL $key ."=".$q."\n"; }