-
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
SourceMap: Don't entertain garbage data (#586) #601
Conversation
Exactly, this line was throwing exception. |
Added a small cleanup commit as well: 80010aa. (spent hours with this code so.. :D) |
This is really great detective work! |
previous_generated_line += 1; | ||
} | ||
result += std::string(generated_line, ';'); | ||
previous_generated_line = generated_line; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this change is doing something very different than the original. Could you please elaborate on the reasoning here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is appending ;
N times (using the (second) overloaded ctor) to result and setting previous_generated_line = generated_line
(exactly what while loop was previously doing).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this is not correct and should look like that instead (??):
result += std::string(generated_line - previous_generated_line, ';');
@am11 you are the one to call this one solved on windows, because nobody else was able to reproduce. If no one else sees any regressions with this I'm all for merging this! Great work @am11, and yeah, I don't really see why this was really causing any issues in the first place! What do you say @xzyfer? |
Perhaps #586 (comment) has some gotcha? I tested it, and it passed the test case under question. The issue I was getting with Windows x64 with Node.js x86 installation. Also, on x64 Windows with x64 node, it was taking a lot of time on running tests (sass/node-sass#497 (comment)). I haven't tested there, but this seems to be the problem. |
I just rebased my [WIP] branch to your latest changes. Lets see what travis ci has to say about it :) My local perl-libsass also compiles fine (strawberry perl on windows with mingw gcc). IMO source maps do need some better testing. I may include more sophisticated tests in |
Having one generic I think we can just trust LESS on that one. It has a lot of source-map related options: CLI C:\temp> node .\node_modules\less\bin\lessc --help
usage: lessc [option option=parameter ...] <source> [destination]
If source is set to `-' (dash or hyphen-minus), input is read from stdin.
options:
...
...
--source-map[=FILENAME] Outputs a v3 sourcemap to the filename (or output filename.map)
--source-map-rootpath=X adds this path onto the sourcemap filename and less file paths
--source-map-basepath=X Sets sourcemap base path, defaults to current working directory.
--source-map-less-inline puts the less files into the map instead of referencing them
--source-map-map-inline puts the map (and any less files) into the output css file
--source-map-url=URL the complete url and filename put in the less file
...
... We can take the inspirations from it's source-maps test and revamp our source-map code to match the details it captures. Even ruby-sass isn't even there yet (#324). The criteria is to capture mapping of as many tokens as possible to establish one-on-one link between source and generated output. |
Feel free to open a more genric issue about source maps! IMP my [WIP] branch actually implements these less options:
|
I can now confirm the issue on node-sass and windows. Also that this PR "fixes" it. |
This is a great news! :) Thanks. I can also confirm it. Just one issue, (we don't have a test for it); in your node-sass root, run var stats = {};
var output = path.join(process.cwd(), './test/fixtures/simple/');
require("./lib/index").renderSync({
file: './test/fixtures/simple/index.scss',
outFile: path.join(output + 'build.css'),
stats: stats,
sourceMap: path.join(output, 'maps/build.css.map')
});
JSON.parse(stats.sourceMap); You will notice that the |
Closing this in favor of #591 |
By the way I think I now understand what the problem was:
|
👍 |
I think we should fix the source of problem. I first built a patch for it: checking if it lies between |
The actual source of the problem is that |
It turned out to be
std::bad_alloc
exception. When source-map column is not updated node-x86 on Windows x64 throws.Turned out, the
generated_position.line
was getting garbage value:std::numeric_limits<size_t>::max()
(4294967295) and its variants: sometimes 4294967293 or 4294967292.This fixes gh-586. 💡
/cc @mgreter, @xzyfer