Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sipi Server crashes when executing Test Script #33

Closed
tobiasschweizer opened this issue Jun 20, 2016 · 12 comments
Closed

Sipi Server crashes when executing Test Script #33

tobiasschweizer opened this issue Jun 20, 2016 · 12 comments
Assignees
Labels
Milestone

Comments

@tobiasschweizer
Copy link
Contributor

When executing test_server/knora_convert_from_binaries.sh, Sipi server crashes with output Segmentation fault: 11

@tobiasschweizer
Copy link
Contributor Author

This seems to happen for each POST route

@tobiasschweizer
Copy link
Contributor Author

SIPI server crashes when receiving a POST request with the header "Content-Type: application/x-www-form-urlencoded"

@tobiasschweizer
Copy link
Contributor Author

in commit 29e675c, in shttps/Connection.cpp, the following lines were removed:

if ((bodybuf = (char *) malloc((content_length + 1)*sizeof(char))) == NULL) {
 -                                throw Error(__file__, __LINE__, "malloc failed!", errno);
 -                            }
 -                            ins->read(bodybuf, content_length);
 -                            if (ins->fail() ||ins->eof()) {
 -                                free(bodybuf);
 -                                throw -1;
 -                            }
 -                            bodybuf[content_length] = '\0';

@tobiasschweizer
Copy link
Contributor Author

as a consequence, bodybuf may be NULL:

if (content_length > 0) {
                    vector<string> content_type_opts = process_header_value(header_in["content-type"]);
                    if (content_type_opts[0] == "application/x-www-form-urlencoded") {
                        char *bodybuf = NULL;
                        if (_chunked_transfer_in) {
                            ChunkReader ckrd(ins);
                            (void) ckrd.readAll(&bodybuf);
                        }
                        else {
                        }
                        string body = bodybuf;
                        post_params = parse_query_string(body, true);
                        request_params.insert(post_params.begin(), post_params.end());

                        free(bodybuf);
                    }

@tobiasschweizer
Copy link
Contributor Author

Starting program: /Users/tobi/gitreps/Sipi-github/local/bin/sipi -config config/sipi.config.lua
[New Thread 0x1313 of process 3268]
[New Thread 0x1403 of process 3268]

Thread 2 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x1313 of process 3268]
0x00007fff8ff4d152 in strlen () from /usr/lib/system/libsystem_c.dylib
(gdb) backtrace
#0  0x00007fff8ff4d152 in strlen () from /usr/lib/system/libsystem_c.dylib
#1  0x000000010003b005 in std::__1::char_traits<char>::length(char const*) ()
#2  0x00000001004a0dec in std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string (this=0x7000000fc6c0, __s=0x0)
    at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:2005
#3  std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string (
    this=0x7000000fc6c0, __s=0x0)
    at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:2003
#4  shttps::Connection::Connection (this=0x700000100608, server_p=0x7fff5fbff310, ins_p=0x700000100a18, 
    os_p=0x700000100968, tmpdir_p=..., buf_size=0, buf_inc=8192)
    at /Users/tobi/gitreps/Sipi-github/lib/shttps/Connection.cpp:480
#5  0x00000001004ac0ad in shttps::Connection::Connection (this=0x700000100608, server_p=0x7fff5fbff310, 
    ins_p=0x700000100a18, os_p=0x700000100968, tmpdir_p=..., buf_size=0, buf_inc=8192)
    at /Users/tobi/gitreps/Sipi-github/lib/shttps/Connection.cpp:361
#6  0x00000001004ed6d4 in shttps::Server::processRequest (this=0x7fff5fbff310, sock=6, peer_ip=..., peer_port=49883)
    at /Users/tobi/gitreps/Sipi-github/lib/shttps/Server.cpp:597
#7  0x00000001004ed0a9 in shttps::process_request (arg=0x100e000a0)
    at /Users/tobi/gitreps/Sipi-github/lib/shttps/Server.cpp:427
#8  0x00007fff9609099d in ?? () from /usr/lib/system/libsystem_pthread.dylib
#9  0x0000000000001103 in ?? ()
#10 0x0000700000104000 in ?? ()
#11 0x0000700000103f50 in ?? ()
#12 0x00007fff9609091a in ?? () from /usr/lib/system/libsystem_pthread.dylib
#13 0x0000000000000000 in ?? ()

@lrosenth
Copy link
Collaborator

Hallo Tobias,
ja, da ist was schief gelaufen. Habe den Code mit malloc wieder rein getan. Bin am testen..

Liebe Grüsse,
Lukas

Prof. Dr. Lukas Rosenthaler
Head of "Digital Humanities Lab",
University of Basel
Bernoullistrasse 32
CH-4056 Basel, Switzerland

Tel: + 41 61 267 0490
Fax: +41 61 267 3855
http://www.dhlab.unibas.ch

On 20 Jun 2016, at 18:52, Tobias Schweizer notifications@github.com wrote:

as a consequence, bodybuf may be NULL:

if (content_length > 0) {
vector content_type_opts = process_header_value(header_in["content-type"]);
if (content_type_opts[0] == "application/x-www-form-urlencoded") {
char *bodybuf = NULL;
if (_chunked_transfer_in) {
ChunkReader ckrd(ins);
(void) ckrd.readAll(&bodybuf);
}
else {
}
string body = bodybuf;
post_params = parse_query_string(body, true);
request_params.insert(post_params.begin(), post_params.end());

                    free(bodybuf);
                }


You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub #33 (comment), or mute the thread https://github.com/notifications/unsubscribe/AFN9zN-qP5T4DuSDRdHDvHL8HLd-pVo5ks5qNsUxgaJpZM4I5pXO.

@tobiasschweizer
Copy link
Contributor Author

Habe mich zunächst nur gewundert, warum da keine POST params mehr sind im Lua script :-)

@tobiasschweizer
Copy link
Contributor Author

ok, openssl branch you have committed your fix to works for me now.

Now this should be fixed in develop to

@lrosenth
Copy link
Collaborator

I’ll do it :-)

Prof. Dr. Lukas Rosenthaler
Head of "Digital Humanities Lab",
University of Basel
Bernoullistrasse 32
CH-4056 Basel, Switzerland

Tel: + 41 61 267 0490
Fax: +41 61 267 3855
http://www.dhlab.unibas.ch

On 21 Jun 2016, at 00:28, Tobias Schweizer notifications@github.com wrote:

ok, openssl branch you have committed your fix to works for me now.

Now this should be fixed in develop to


You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub #33 (comment), or mute the thread https://github.com/notifications/unsubscribe/AFN9zOxkSQwJuwF_oplJ96eaqJSIUWvWks5qNxQqgaJpZM4I5pXO.

@tobiasschweizer
Copy link
Contributor Author

great :-)

@BiancoA
Copy link
Contributor

BiancoA commented Aug 26, 2016

solved?

@lrosenth
Copy link
Collaborator

Solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants