“hello world” c cgi script crashes on server”Difference between the Apache HTTP Server and Apache Tomcat?What's the difference between proxy server and reverse proxy server?How do I prompt for Yes/No/Cancel input in a Linux shell script?Why doesn't “cd” work in a shell script?Pipe to/from the clipboard in Bash scriptWhat is the difference between application server and web server?What is Common Gateway Interface (CGI)?Using node.js as a simple web serverRemote C-based CGI Script Crashing In __libc_start_main()Cannot install atari-py on RedHat Enterprise server with c compiler broken error

Why do presidential pardons exist in a country having a clear separation of powers?

How to investigate an unknown 1.5GB file named "sudo" in my Linux home directory?

Do universities maintain secret textbooks?

How to Flip Rotation from Positive to Negative?

Quick Tilepaint Puzzles: Corridors and Corners

IList<T> implementation

How do I get my neighbour to stop disturbing with loud music?

How is the casino term "a high roller" commonly expressed in German?

Can authors email you PDFs of their textbook for free?

How can I improve my formal definitions?

Cheap oscilloscope showing 16 MHz square wave

Moscow SVO airport, how to avoid scam taxis without pre-booking?

Why haven't the British protested Brexit as ardently like Hong Kongers protest?

Heavy Box Stacking

How to prevent graphics clipping through each other

Who declared the Last Alliance to be the "last" and why?

Comparative evolutionary study: is amino acid or nucleotide comparison more useful?

What is the following VRP?

How to run a command 1 out of N times in Bash

Resources to learn about firearms?

Am I required to correct my opponent's assumptions about my morph creatures?

What's the origin of the concept of alternate dimensions/realities?

I failed to respond to a potential advisor

ELI5 what is SMTChecker?



“hello world” c cgi script crashes on server”


Difference between the Apache HTTP Server and Apache Tomcat?What's the difference between proxy server and reverse proxy server?How do I prompt for Yes/No/Cancel input in a Linux shell script?Why doesn't “cd” work in a shell script?Pipe to/from the clipboard in Bash scriptWhat is the difference between application server and web server?What is Common Gateway Interface (CGI)?Using node.js as a simple web serverRemote C-based CGI Script Crashing In __libc_start_main()Cannot install atari-py on RedHat Enterprise server with c compiler broken error






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I'm trying to execute a simple c cgi-script on a hosted webserver. I compiled this code:



#include <stdio.h>

int main()
printf("Content-type: text/plainnn");
printf("<html>n");
printf("<head><title>Testing CGI-Scripts</title></head>n");
printf("<body>n");
printf("<h1>Hello World</h1>n");
printf("</body>n");
printf("</html>n");
return 0;



with gcc -o index.cgi index.c, uploaded the binary to the cgi-bin directory and changed the permission to 755. Yet when executing the script (url/cgi-bin/index.cgi) it causes a core-dump and I'm getting "500 Internal Server Error". Analyzing the core-dump with gdb got me "Cannot access memory at address 0x3000000000008" and the same line with "0x3000000000000".



I tried:



  • compiling on Ubuntu 11.10 (because auf kernel 3.0)

  • compiling with -static

(Analysis with gdb from the static binary:



Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0000000000401e82 in __libc_start_main ()


)



My System: Arch Linux, kernel 4.20.12 x86_64



Server: CloudLinux 7, kernel 3.10.0-962.3.2.lve1.5.24.8.el7 x86_64



I do not have shell access, unfortunately.




Edit: Solution:



Building a static binary on a virtual machine with CentOS (on which the Servers distro is based on) installed worked!










share|improve this question


























  • Linking libc static can fail easily because it still tries to link other, dynamic components "by foot". If you want to build a static binary I would recommend to use an alternative libc implementation, as for example uclibc. Usually, a script language, which is available at the webserver environment, is used for CGI however. A shell script for example, or perl, python, whatever.

    – Ctx
    Mar 27 at 23:42












  • @Ctx Thank you, I'm gonna give uclibc a shot.

    – rn42v1r
    Mar 27 at 23:49

















3















I'm trying to execute a simple c cgi-script on a hosted webserver. I compiled this code:



#include <stdio.h>

int main()
printf("Content-type: text/plainnn");
printf("<html>n");
printf("<head><title>Testing CGI-Scripts</title></head>n");
printf("<body>n");
printf("<h1>Hello World</h1>n");
printf("</body>n");
printf("</html>n");
return 0;



with gcc -o index.cgi index.c, uploaded the binary to the cgi-bin directory and changed the permission to 755. Yet when executing the script (url/cgi-bin/index.cgi) it causes a core-dump and I'm getting "500 Internal Server Error". Analyzing the core-dump with gdb got me "Cannot access memory at address 0x3000000000008" and the same line with "0x3000000000000".



I tried:



  • compiling on Ubuntu 11.10 (because auf kernel 3.0)

  • compiling with -static

(Analysis with gdb from the static binary:



Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0000000000401e82 in __libc_start_main ()


)



My System: Arch Linux, kernel 4.20.12 x86_64



Server: CloudLinux 7, kernel 3.10.0-962.3.2.lve1.5.24.8.el7 x86_64



I do not have shell access, unfortunately.




Edit: Solution:



Building a static binary on a virtual machine with CentOS (on which the Servers distro is based on) installed worked!










share|improve this question


























  • Linking libc static can fail easily because it still tries to link other, dynamic components "by foot". If you want to build a static binary I would recommend to use an alternative libc implementation, as for example uclibc. Usually, a script language, which is available at the webserver environment, is used for CGI however. A shell script for example, or perl, python, whatever.

    – Ctx
    Mar 27 at 23:42












  • @Ctx Thank you, I'm gonna give uclibc a shot.

    – rn42v1r
    Mar 27 at 23:49













3












3








3








I'm trying to execute a simple c cgi-script on a hosted webserver. I compiled this code:



#include <stdio.h>

int main()
printf("Content-type: text/plainnn");
printf("<html>n");
printf("<head><title>Testing CGI-Scripts</title></head>n");
printf("<body>n");
printf("<h1>Hello World</h1>n");
printf("</body>n");
printf("</html>n");
return 0;



with gcc -o index.cgi index.c, uploaded the binary to the cgi-bin directory and changed the permission to 755. Yet when executing the script (url/cgi-bin/index.cgi) it causes a core-dump and I'm getting "500 Internal Server Error". Analyzing the core-dump with gdb got me "Cannot access memory at address 0x3000000000008" and the same line with "0x3000000000000".



I tried:



  • compiling on Ubuntu 11.10 (because auf kernel 3.0)

  • compiling with -static

(Analysis with gdb from the static binary:



Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0000000000401e82 in __libc_start_main ()


)



My System: Arch Linux, kernel 4.20.12 x86_64



Server: CloudLinux 7, kernel 3.10.0-962.3.2.lve1.5.24.8.el7 x86_64



I do not have shell access, unfortunately.




Edit: Solution:



Building a static binary on a virtual machine with CentOS (on which the Servers distro is based on) installed worked!










share|improve this question
















I'm trying to execute a simple c cgi-script on a hosted webserver. I compiled this code:



#include <stdio.h>

int main()
printf("Content-type: text/plainnn");
printf("<html>n");
printf("<head><title>Testing CGI-Scripts</title></head>n");
printf("<body>n");
printf("<h1>Hello World</h1>n");
printf("</body>n");
printf("</html>n");
return 0;



with gcc -o index.cgi index.c, uploaded the binary to the cgi-bin directory and changed the permission to 755. Yet when executing the script (url/cgi-bin/index.cgi) it causes a core-dump and I'm getting "500 Internal Server Error". Analyzing the core-dump with gdb got me "Cannot access memory at address 0x3000000000008" and the same line with "0x3000000000000".



I tried:



  • compiling on Ubuntu 11.10 (because auf kernel 3.0)

  • compiling with -static

(Analysis with gdb from the static binary:



Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0000000000401e82 in __libc_start_main ()


)



My System: Arch Linux, kernel 4.20.12 x86_64



Server: CloudLinux 7, kernel 3.10.0-962.3.2.lve1.5.24.8.el7 x86_64



I do not have shell access, unfortunately.




Edit: Solution:



Building a static binary on a virtual machine with CentOS (on which the Servers distro is based on) installed worked!







c linux webserver cgi hosting






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 13:07







rn42v1r

















asked Mar 27 at 23:35









rn42v1rrn42v1r

254 bronze badges




254 bronze badges















  • Linking libc static can fail easily because it still tries to link other, dynamic components "by foot". If you want to build a static binary I would recommend to use an alternative libc implementation, as for example uclibc. Usually, a script language, which is available at the webserver environment, is used for CGI however. A shell script for example, or perl, python, whatever.

    – Ctx
    Mar 27 at 23:42












  • @Ctx Thank you, I'm gonna give uclibc a shot.

    – rn42v1r
    Mar 27 at 23:49

















  • Linking libc static can fail easily because it still tries to link other, dynamic components "by foot". If you want to build a static binary I would recommend to use an alternative libc implementation, as for example uclibc. Usually, a script language, which is available at the webserver environment, is used for CGI however. A shell script for example, or perl, python, whatever.

    – Ctx
    Mar 27 at 23:42












  • @Ctx Thank you, I'm gonna give uclibc a shot.

    – rn42v1r
    Mar 27 at 23:49
















Linking libc static can fail easily because it still tries to link other, dynamic components "by foot". If you want to build a static binary I would recommend to use an alternative libc implementation, as for example uclibc. Usually, a script language, which is available at the webserver environment, is used for CGI however. A shell script for example, or perl, python, whatever.

– Ctx
Mar 27 at 23:42






Linking libc static can fail easily because it still tries to link other, dynamic components "by foot". If you want to build a static binary I would recommend to use an alternative libc implementation, as for example uclibc. Usually, a script language, which is available at the webserver environment, is used for CGI however. A shell script for example, or perl, python, whatever.

– Ctx
Mar 27 at 23:42














@Ctx Thank you, I'm gonna give uclibc a shot.

– rn42v1r
Mar 27 at 23:49





@Ctx Thank you, I'm gonna give uclibc a shot.

– rn42v1r
Mar 27 at 23:49












1 Answer
1






active

oldest

votes


















1















The libraries and linker behavior may vary widely. The two distributions in question aren't even running on the same major kernel version. It sounds like you're compiling against a significantly newer version of glibc than the one that exists on your server.



I recommend you set up cross-compilation or run CloudLinux 7 in a virtual machine and compile in the VM.






share|improve this answer




















  • 1





    Thanks alot, setting up a virtual machine with CentOS 7 (which CloudLinux 7 is based on) and then building a static binary worked!

    – rn42v1r
    Mar 28 at 13:03











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388080%2fhello-world-c-cgi-script-crashes-on-server%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1















The libraries and linker behavior may vary widely. The two distributions in question aren't even running on the same major kernel version. It sounds like you're compiling against a significantly newer version of glibc than the one that exists on your server.



I recommend you set up cross-compilation or run CloudLinux 7 in a virtual machine and compile in the VM.






share|improve this answer




















  • 1





    Thanks alot, setting up a virtual machine with CentOS 7 (which CloudLinux 7 is based on) and then building a static binary worked!

    – rn42v1r
    Mar 28 at 13:03
















1















The libraries and linker behavior may vary widely. The two distributions in question aren't even running on the same major kernel version. It sounds like you're compiling against a significantly newer version of glibc than the one that exists on your server.



I recommend you set up cross-compilation or run CloudLinux 7 in a virtual machine and compile in the VM.






share|improve this answer




















  • 1





    Thanks alot, setting up a virtual machine with CentOS 7 (which CloudLinux 7 is based on) and then building a static binary worked!

    – rn42v1r
    Mar 28 at 13:03














1














1










1









The libraries and linker behavior may vary widely. The two distributions in question aren't even running on the same major kernel version. It sounds like you're compiling against a significantly newer version of glibc than the one that exists on your server.



I recommend you set up cross-compilation or run CloudLinux 7 in a virtual machine and compile in the VM.






share|improve this answer













The libraries and linker behavior may vary widely. The two distributions in question aren't even running on the same major kernel version. It sounds like you're compiling against a significantly newer version of glibc than the one that exists on your server.



I recommend you set up cross-compilation or run CloudLinux 7 in a virtual machine and compile in the VM.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 27 at 23:51









torstenvltorstenvl

7576 silver badges14 bronze badges




7576 silver badges14 bronze badges










  • 1





    Thanks alot, setting up a virtual machine with CentOS 7 (which CloudLinux 7 is based on) and then building a static binary worked!

    – rn42v1r
    Mar 28 at 13:03













  • 1





    Thanks alot, setting up a virtual machine with CentOS 7 (which CloudLinux 7 is based on) and then building a static binary worked!

    – rn42v1r
    Mar 28 at 13:03








1




1





Thanks alot, setting up a virtual machine with CentOS 7 (which CloudLinux 7 is based on) and then building a static binary worked!

– rn42v1r
Mar 28 at 13:03






Thanks alot, setting up a virtual machine with CentOS 7 (which CloudLinux 7 is based on) and then building a static binary worked!

– rn42v1r
Mar 28 at 13:03









Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388080%2fhello-world-c-cgi-script-crashes-on-server%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해