-
Notifications
You must be signed in to change notification settings - Fork 2
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
Crash: libc++abi: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc #67
Comments
I couldn't reproduce it with the html2md executable and the web version of MarkdownEdit (File -> import -> HTML). How did you call it and which options did u use? |
Can you try the following code: for (int i = 0; i < 2; i++) {
html2md::Options options;
options.splitLines = false;
QString html1 = "<meta charset='utf-8'><table border=\"0\" style=\"font-family: Verdana, Geneva, sans-serif; letter-spacing: normal; orphans: 2; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(246, 246, 239); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;\"><tbody><tr><td class=\"ind\" indent=\"0\" style=\"font-family: Verdana, Geneva, sans-serif; font-size: 10pt; color: rgb(130, 130, 130);\"><img src=\"https://news.ycombinator.com/s.gif\" height=\"1\" width=\"0\"></td><td valign=\"top\" class=\"votelinks\" style=\"font-family: Verdana, Geneva, sans-serif; font-size: 10pt; color: rgb(130, 130, 130);\"><center><a id=\"up_21885445\" class=\"clicky\" href=\"https://news.ycombinator.com/vote?id=21885445&how=up&auth=4ab46530c8158343f958f2cda580e250bcc8e667&goto=item%3Fid%3D21884828#21885445\" style=\"color: rgb(0, 0, 0); text-decoration: none;\"><div class=\"votearrow\" title=\"upvote\" style=\"width: 10px; height: 10px; border: 0px; margin: 3px 2px 6px; background: url("triangle.svg") 0% 0% / 10px, linear-gradient(transparent, transparent) no-repeat;\"></div></a></center></td><td class=\"default\" style=\"font-family: Verdana, Geneva, sans-serif; font-size: 10pt; color: rgb(130, 130, 130);\"><div style=\"margin-top: 2px; margin-bottom: -10px;\"><span class=\"comhead\" style=\"font-family: Verdana, Geneva, sans-serif; font-size: 8pt; color: rgb(130, 130, 130);\"><a href=\"https://news.ycombinator.com/user?id=brudgers\" class=\"hnuser\" style=\"color: rgb(130, 130, 130); text-decoration: none;\">brudgers</a><span> </span><span class=\"age\" title=\"2019-12-26T17:52:06\"><a href=\"https://news.ycombinator.com/item?id=21885445\" style=\"color: rgb(130, 130, 130); text-decoration: none;\">on Dec 27, 2019</a></span><span> </span><span id=\"unv_21885445\"></span><span class=\"navs\">|<span> </span><a href=\"https://news.ycombinator.com/item?id=21884828#21894436\" class=\"clicky\" aria-hidden=\"true\" style=\"color: rgb(130, 130, 130); text-decoration: none;\">next</a><span> </span><a class=\"togg clicky\" id=\"21885445\" n=\"28\" href=\"javascript:void(0)\" style=\"color: rgb(130, 130, 130); text-decoration: none;\">[–]</a><span class=\"onstory\"></span></span></span></div><br><div class=\"comment\" style=\"font-family: Verdana, Geneva, sans-serif; font-size: 9pt; max-width: 970px; overflow-wrap: anywhere; overflow: hidden;\"><span class=\"commtext c00\" style=\"color: rgb(0, 0, 0);\">Excel alternatives might be uncountable. Implementing spreadsheet basics is an advanced beginner exercise. But even Google’s billions only get it a distant second best because Microsoft is still working hard despite the lead. Sure Google and Apple can meet most needs most of the time. They’re good enough mainly because they are free beer. Not because they are open source. Obviously.</span></div></td></tr></tbody></table>";
std::string html2 = html1.toStdString();
html2md::Converter c(html2, &options);
c.convert();
} I see it happens only on the second/third time I call the paste function so I put it in a loop. Am I doing something incorrectly (other than the inefficiency of the sample code)? |
I still can't reproduce it, even after running it 100 times. 😞 |
Weird. Then it's probably something on my end. I'll investigate more and let you know. |
Did you found the bug? |
Hey, I encountered other bugs in my code so I'll get to this one later hah. You can close this issue and I'll reopen it if I find the bug is still related to this library. |
Nah, there clearly must be a bug in my library so let's leave it open till we find it. But good luck with you other problems! I would like to help you but don't have the time right now |
No worries, as soon as I find something I'll let you know. |
Hey, Tim. I'm back to debug this issue. For some reason the debugger doesn't show any meaningful stuff. This is basically all I'm doing in my code: const QMimeData *clipboardMimeData = m_clipboard->mimeData();
if (clipboardMimeData->hasHtml()) {
qDebug() << "Hello 1";
html2md::Options options;
qDebug() << "Hello 2";
options.splitLines = false;
qDebug() << "Hello 3";
std::string html = clipboardMimeData->html().toStdString();
qDebug() << "Hello 4";
html2md::Converter c(html, &options);
qDebug() << "Hello 5";
std::string result = c.convert();
qDebug() << "Hello 6";
QString markdown = QString::fromStdString(result);
qDebug() << "Hello 7";
pasteMarkdown(markdown);
qDebug() << "Hello 8";
}
It crashes when I copy a bunch of things from HackerNews, for example, a bunch of my comments together: https://news.ycombinator.com/threads?id=rubymamis |
Can I find the exact code (of the whole program) somewhere? And could you please embed the HTML in the code? Because when I copy comments from the site, it copies them as plain text |
I think I found where it crashes. In table.cpp |
It should work now. Can you please test it? If it works I'll create a new release |
Yay, it works! Thanks a lot. |
Hey again Tim!
I tried to paste some HTML from HackerNews into my note app and it crashed on the
convert()
function. This is the HTML that was copied from the clipboard:Can you verify if you also experience this?
The text was updated successfully, but these errors were encountered: