Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

System Call in CGI script - Memory read error

System Call in CGI script - Memory read error

System Call in CGI script - Memory read error


I created a file upload webpage and what it is supposed to do is to take the file, run the C++ program in the server with a system call, and then return the result.

Before calling my own C++ program, I also created a simple "HelloWorld" program for testing purposes, which simply prints "Hello World" and some other strings.

But my main C++ program gets a file as an argument, reads it, print results to command prompt and files, creates many files and some output in the command window.

The relevant webpage is here: idefix.cs.rpi.edu/SpolGraph/SPOLGRAPH_RUN.html

The cgi code that is called when "Submit" button is clicked, is as follows:


use strict;
use DBI;
use File::Basename;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use Spreadsheet::WriteExcel;
require "cgi-lib.pl";

my $Directory = "C:\\wamp\\www\\cgi";
#my $Url_Path = "";

my $File_Name = param('inputfile');
my $email = param('email');
my $familyType = param('family');
my $graphType = param('graphType');
my $randomizer = param('randomizer');

my $File = Get_File_Name($File_Name);
my $FileNamerrr = 'C:\\wamp\\www\\cgi\\supplyData434Small';

$CGI::POST_MAX = 1024 * 2500; #2500 KB data is allowed


sub Get_File_Name
    if($ENV{HTTP_USER_AGENT} =~ /win/i)
    elsif($ENV{HTTP_USER_AGENT} =~ /mac/i)
    my $full_name = shift;
    $full_name = basename($full_name);
    $full_name =~ s!\s!\_!g;

sub Store_Results
    my $data;
    my $mime = uploadInfo($File_Name)->{'Content-Type'};
    open(STORAGE, ">$Directory/$File") or die "Error: $Directory/$File: $!\n";
    if($mime !~ /text/)
    while( read($File_Name, $data, 1024) )
        print STORAGE $data;
    close STORAGE;

sub Print_Results()
    print header;
    print qq(<PRE><B>File Name:</B> $File_Name\n);
    print qq(<PRE><B>File:</B> $File\n);
    print qq(<B>email:</B> $email\n);
    print qq(<B>Family Type:</B> $familyType\n);
    print qq(<B>Graph Type:</B> $graphType\n);
    print qq(<B>Randomizer:</B> $randomizer\n);
    #print qq(<B>File Contents:</B><XMP>\n\n);
    #    print;
    #print qq($File_Name\t$email\t$familyType\t$graphType\t$randomizer\n);
    system('C:\Documents and Settings\Amina\Desktop\HelloWorld\debug\HelloWorld.exe', 'aaa');
    #system(cmd, '\c');
    #print qq($FileNamerrr \n);
    system('C:\Documents and Settings\Amina\Desktop\SpolGraph\debug\SpolGraph.exe', $FileNamerrr, $familyType, $graphType, $randomizer); #cmd, '\c'
    print qq(<XMP>);    
    print qq(</XMP></PRE>);
    print qq(<h3><font color="blue">Thank You for using SPOLGRAPH!</font></h3>);
    print qq(<p>Return to <a href="http://cgi2.cs.rpi.edu/~ozcagc2/SPOLGRAPH.html">SPOLGRAPH Home </a>);
    print qq(or <a href="http://cgi2.cs.rpi.edu/~ozcagc2/SPOLGRAPH_RUN.html">Enter another data</a></p>);
    print end_html;

Now, first system call for "HelloWorld.exe" works, the correct output is printed on the webpage.

The system call for "SpolGraph.exe" starts execution, goes up to some point, it prints some output to webpage, it even creates and partly fills files that it is supposed to fill in with values(I can check this on the folder of server side), but it always crashes. The output until the program crashes and error message returned in the server are as follows:



File Name: supplyData434Small.txt
File: supplyData434Small.txt
email: ozcagc2@cs.rpi.edu
Family Type: CDC
Graph Type: Spoligotype
Randomizer: Seeded
Hello World Testerrrrr: aaabbb
C:\Documents and Settings\Amina\Desktop\SpolGraph\debug\SpolGraph.exe C:\wamp\www\cgi\supplyData434Small CDC Spoligotype Seeded
Type something!!!

Error message:


The instruction at "0x004223db" referenced memory at "0xbae8ce97". The memory could not be "read".

Click on OK to terminate the program.
Click on CANCEL to debug the program.

Now what is missing here? It is not because of the absolute path problem, I fixed it and that's how "HelloWorld" program works. So, what is the problem? I ran this "SpolGraph" program as a standalone application in various computers(both in server and client side), and they worked. But what is it now that causes this memory read error? I'm assuming I uploaded the file correctly, because I can see the uploaded file in the relevant folder in the server, and all that is need to be done is to run this "SpolGraph" program with the relevant system call in the code above. Any ideas are appreciated.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close