-
Notifications
You must be signed in to change notification settings - Fork 464
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
MSVC x86_64 buffer overrun in error reporting (Regression between 3.3.5 and 3.3.6) #2046
Comments
First 👏 for that bug report, pretty much on spot as we want them. If you take the time to replace Already getting late here, but will take a quick peek ... |
Seems removing |
Will do and report back. I'm out of space on my SSD so I'll probably need to spin up a VM |
Changing to Thanks for the tip! |
Hmmm... this is slightly difficult to do since those are some defaults that are difficult to override -- any idea why this commit breaks |
Yeah, because memory is probably more scrambled, so it is probably also easier to get segfaults via dangling pointers or buffer overruns etc. But I can already report that it is a dreaded, hard to spot "issue" we are actually not facing for the first time. Fix is underway, will write a bit more in the PR. |
<3 you're the best |
If you like to give it a thought yourself, this is the offending line:
|
See #2048 for proposed fix. Thanks for the report! |
I do remember something similar to this in some code I wrote a long while back -- I thought the standard protected against the string temporary being collected but perhaps not. This patch seems to make the code succeed: diff --git a/src/sass_context.cpp b/src/sass_context.cpp
index e3f34af..9105866 100644
--- a/src/sass_context.cpp
+++ b/src/sass_context.cpp
@@ -140,7 +140,8 @@ extern "C" {
json_append_member(json_err, "message", json_mkstring(e.what()));
json_append_member(json_err, "formatted", json_mkstring(msg_stream.str().c_str()));
try { c_ctx->error_json = json_stringify(json_err, " "); } catch(...) {}
- c_ctx->error_message = sass_copy_c_string(msg_stream.str().c_str());
+ std::string s = msg_stream.str();
+ c_ctx->error_message = sass_copy_c_string(s.c_str());
c_ctx->error_text = sass_copy_c_string(e.what());
c_ctx->error_status = 3;
c_ctx->output_string = 0;
|
oh sweet, we came to the same conclusion :D |
Yep, saw that one before with the memory management, where destructor was called in an odd ordering that lead to basically the same issue (same compiler). |
Ah, now I remember, that is exactly the reason (AFAIR) why we have the |
Nice catch y'all
|
This originally comes from sass/libsass-python#149
I'm having a hard time wrapping my head around exactly why this happens, but I'll post what I've got so far :)
This commit seems to cause the issue I'm seeing: 527f3a8 (#2025)
Checking out the revision before it (f8cad4e) seems to succeed.
My little test harness
You can view the code here if that's easier: https://github.com/asottile/libsass/commit/f40ae24025234b73ca86adece62dec0e35884eb1
main.cpp
test.bat
Output at f8cad4e
Output at 527f3a8
Attaching debugger on failure gives the following message:
And drops a breakpoint at: https://github.com/sass/libsass/blob/527f3a8/src/sass_context.cpp#L143
The text was updated successfully, but these errors were encountered: