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

adding DOMParser to code leads to stack smashing #4060

Closed
omerbrandis opened this issue Jun 20, 2023 · 5 comments
Closed

adding DOMParser to code leads to stack smashing #4060

omerbrandis opened this issue Jun 20, 2023 · 5 comments
Labels

Comments

@omerbrandis
Copy link
Contributor

hello

these are my first steps with Poco::XML
I'm trying to follow the tutorial presentations to parse an xml string.
i'm currently using poco version 1.11.

simply adding "Poco::XML::DOMParser parser;" to a class method, leads to a stack smashing crash during the function's return.
in other words the function ends with
Poco::XML::DOMParser parser;
return (myStruct);

and the caller :
returnStruct = myFunction;
std::cout<< "after call" << std::endl;

on execution :
does not print out "after call". ( when i remove the definition of the dom parser, the return works as expected ).

i do get :
*** stack smashing detected ***: ./PocoWebServer terminated
Aborted (core dumped)

here's the stack trace:
Program terminated with signal SIGABRT, Aborted.
#0 0x00007f897cc52428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
[Current thread is 1 (Thread 0x7f897b9b6700 (LWP 6616))]
(gdb) bt
#0 0x00007f897cc52428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007f897cc5402a in __GI_abort () at abort.c:89
#2 0x00007f897cc947ea in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7f897cdac49f "*** %s **: %s terminated\n") at ../sysdeps/posix/libc_fatal.c:175
#3 0x00007f897cd3615c in __GI___fortify_fail (msg=, msg@entry=0x7f897cdac481 "stack smashing detected") at fortify_fail.c:37
#4 0x00007f897cd36100 in __stack_chk_fail () at stack_chk_fail.c:28
#5 0x000000000047f3f9 in ServeSearchRequestHandler::myfunction() ()
#6 0x000000000047b32c in ServeSearchRequestHandler::handleRequest(Poco::Net::HTTPServerRequest&, Poco::Net::HTTPServerResponse&) ()
#7 0x00007f897ddd5ba7 in Poco::Net::HTTPServerConnection::run() () at /home/omerbrandis/ffrobotics/poco-1.11.0-all/Net/src/HTTPServerConnection.cpp:85
#8 0x00007f897ddf2957 in Poco::Net::TCPServerConnection::start() () at /home/omerbrandis/ffrobotics/poco-1.11.0-all/Net/src/TCPServerConnection.cpp:43
#9 0x00007f897dde0a36 in Poco::Net::TCPServerDispatcher::run() () at /home/omerbrandis/ffrobotics/poco-1.11.0-all/Net/src/TCPServerDispatcher.cpp:119
#10 0x00007f897e3c38af in Poco::PooledThread::run() () at /home/omerbrandis/ffrobotics/poco-1.11.0-all/Foundation/src/ThreadPool.cpp:199
#11 0x00007f897e41cef9 in Poco::ThreadImpl::runnableEntry(void
) () at /home/omerbrandis/ffrobotics/poco-1.11.0-all/Foundation/src/Thread_POSIX.cpp:342
#12 0x00007f897d5ea6ba in start_thread (arg=0x7f897b9b6700) at pthread_create.c:333
#13 0x00007f897cd2441d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

any ideas would be very welcome.
Omer.
:-)

@omerbrandis
Copy link
Contributor Author

hello

this still occurs in poco v 1.12.4
using gcc 8.4.0 .

minimal reproducible example :
Poco::AutoPtrPoco::XML::Document pDoc = new Poco::XML::Document;
Poco::AutoPtrPoco::XML::Element pRoot = pDoc->createElement("root");
pDoc->appendChild(pRoot);

try
{
Poco::XML::DOMWriter writer;
writer.setNewLine("\n");
writer.setOptions(Poco::XML::XMLWriter::PRETTY_PRINT);
writer.writeNode(std::cout, pDoc);
}
catch (const Poco::XML::XMLException & Except)
{
std::cout << "xml writer threw " << Except.displayText() <<std::endl;
}

please advise,

@omerbrandis
Copy link
Contributor Author

gdb bt :
#0 0x00007f29266fc428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007f29266fe02a in __GI_abort () at abort.c:89
#2 0x00007f292673e7ea in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7f292685649f "*** %s ***: %s terminated\n") at ../sysdeps/posix/libc_fatal.c:175
#3 0x00007f29267e015c in __GI___fortify_fail (msg=, msg@entry=0x7f2926856481 "stack smashing detected") at fortify_fail.c:37
#4 0x00007f29267e0100 in __stack_chk_fail () at stack_chk_fail.c:28
#5 0x00000000004178be in myfunction() ()
#6 0x00000000004116de in main ()

@omerbrandis
Copy link
Contributor Author

seems that the instantiation of the Poco::XML::DOMWriter writer; is enough to cause the error

Copy link

This issue is stale because it has been open for 365 days with no activity.

@github-actions github-actions bot added the stale label Sep 27, 2024
Copy link

This issue was closed because it has been inactive for 60 days since being marked as stale.

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

1 participant