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

Invalid multiplication (px * px) crashes #789

Closed
mgreter opened this issue Dec 30, 2014 · 24 comments
Closed

Invalid multiplication (px * px) crashes #789

mgreter opened this issue Dec 30, 2014 · 24 comments
Assignees
Milestone

Comments

@mgreter
Copy link
Contributor

mgreter commented Dec 30, 2014

This code produces a crash with current master:

div {
    $a: 1px;
    $b: 2px;
    foo: $a * $b;
}

The test suite does not include this case!
All other math operations work correctly!

@mgreter mgreter changed the title Regression in latest beta Regression with multiplication in latest beta Dec 30, 2014
@mgreter mgreter added this to the 3.1 milestone Dec 30, 2014
@KittyGiraudel
Copy link

Actually Ruby Sass doesn't allow this calculation either.

2px*px isn't a valid CSS value.

@mgreter
Copy link
Contributor Author

mgreter commented Dec 30, 2014

@hugogiraudel Thanks for the heads up. IMO this is still a valid report as it should not crash! Or could you not reproduce the crash @xzyfer ?

@xzyfer
Copy link
Contributor

xzyfer commented Dec 30, 2014

@mgreter you're correct. Sorry I got a bit overzealous

@xzyfer xzyfer reopened this Dec 30, 2014
@mgreter mgreter changed the title Regression with multiplication in latest beta Invalid multiplication (px * px) crashes Dec 30, 2014
@mgreter mgreter modified the milestones: 3.next, 3.1 Dec 30, 2014
@xzyfer xzyfer mentioned this issue Dec 30, 2014
12 tasks
@xzyfer
Copy link
Contributor

xzyfer commented Dec 30, 2014

@mgreter I've had a look at this and after a clean recompile I can't reproduce the crash. It errors as expected with the following

2px*px is not a valid CSS value

@xzyfer xzyfer closed this as completed Dec 30, 2014
@drewwells
Copy link
Contributor

I'm reproducing this on sha 420d7fb

div {
    $a: 1px;
    $b: 2px;
    foo: $a * $b;
}

terminate called after throwing an instance of 'Sass::Sass_Error'
SIGABRT: abort
PC=0x7f6ce215f107
signal arrived during cgo execution

@xzyfer
Copy link
Contributor

xzyfer commented Dec 30, 2014

Interesting, I cannot produce this on that commit. I'm on OSX 10.9.5

$ cpp --version
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
$ sassc --version
sassc: 3.0.2-14-g65d2
libsass: 3.1.0-beta.2-2-g420d
sass2scss: 1.0.3
$ (cd sassc; git rev-parse HEAD)
65d2bdbb48987acb1e68dd926ed23d4f19ccc271

$ (cd libsass; git rev-parse HEAD)
420d7fb4e578857150e15d80c966e5cac779d932

@drewwells
Copy link
Contributor

I'm reproducing on OS X and linux:

Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

@xzyfer
Copy link
Contributor

xzyfer commented Dec 30, 2014

@drewwells can you please run the commands in my previous message and update the output in your comment.

@xzyfer xzyfer reopened this Dec 30, 2014
@drewwells
Copy link
Contributor

I'm running the following Sass. What command did you want me to try?

div {
    $a: 1px;
    $b: 2px;
    foo: $a * $b;
}

@xzyfer
Copy link
Contributor

xzyfer commented Dec 30, 2014

$ cpp --version
$ sassc --version
$ (cd sassc; git rev-parse HEAD)
$ (cd libsass; git rev-parse HEAD)

@drewwells
Copy link
Contributor

Ahh, I'm not running Sassc I'm running my implementation of libsass.

-> % cpp --version
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
-> % cd libsass; git rev-parse HEAD
420d7fb4e578857150e15d80c966e5cac779d932

@xzyfer
Copy link
Contributor

xzyfer commented Dec 30, 2014

@drewwells
Copy link
Contributor

I'm working through setting up gdb debugging on OS X. I'm not having much luck getting it to work with cgo (golang linker) though.

@drewwells
Copy link
Contributor

Aha, this is why I'm having so much trouble: golang/go#5221

On linux,

rogram received signal SIGABRT, Aborted.
0x00007ffff7029107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56  ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff7029107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff702a4e8 in __GI_abort () at abort.c:89
#2  0x00007ffff7b31b3d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff7b2fbb6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff7b2fc01 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff7b2fe19 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00000000007cf481 in Sass::error (msg="2px*px is not a valid CSS value", path="stdin", position=...) at error_handling.cpp:15
#7  0x0000000000767acf in Sass::Inspect::operator() (this=<optimized out>, n=0xd2ad80) at inspect.cpp:372
#8  0x0000000000760ebc in Sass::Inspect::operator() (this=0x210, dec=0x210) at inspect.cpp:94
#9  0x0000000000779c6f in fallback_impl (n=0xd2ae20, this=0x7fffffffea60) at output_nested.cpp:22
#10 fallback<Sass::Declaration*> (x=0xd2ae20, this=0x7fffffffea60) at output_nested.hpp:102
#11 Sass::Operation_CRTP<void, Sass::Output_Nested>::operator() (this=0x7fffffffea60, x=0xd2ae20) at operation.hpp:93
#12 0x0000000000778e78 in Sass::Output_Nested::operator() (this=0x7fffffffea60, r=<optimized out>) at output_nested.cpp:115
#13 0x00000000007774e9 in Sass::Output_Nested::operator() (this=0x210, this@entry=0x7fffffffea60, b=0x210, b@entry=0xd2a1b0) at output_nested.cpp:52
#14 0x00000000006f5837 in perform (op=0x7fffffffea60, this=0xd2a1b0) at ast.hpp:290
#15 Sass::Context::compile_block (this=this@entry=0xd08fd0, root=0xd2a1b0) at context.cpp:244
#16 0x00000000006eaf81 in sass_compiler_execute (compiler=0xd08fa0) at sass_context.cpp:549
#17 0x000000000044dc77 in _cgo_22273bb0d233_Cfunc_sass_compiler_execute (v=0xc208085998) at /go/src/github.com/wellington/wellington/context/context.go:52
#18 0x000000000048b3f5 in asmcgocall () at /usr/src/go/src/runtime/asm_amd64.s:665
#19 0x000000c208085950 in ?? ()
#20 0x0000000000000008 in ?? ()
#21 0x000000c20804cbc0 in ?? ()
#22 0x000000000044fd19 in runtime.cgocall_errno (fn=0x489d25 <runtime.rt0_go+293>, arg=0x0, ~r2=4758828) at /usr/src/go/src/runtime/cgocall.go:117
#23 0x0000000000480054 in runtime.mstart () at /usr/src/go/src/runtime/proc.c:836
#24 0x0000000000489d2c in runtime.rt0_go () at /usr/src/go/src/runtime/asm_amd64.s:106
#25 0x0000000000000001 in ?? ()
#26 0x00007fffffffeca8 in ?? ()
#27 0x0000000000000001 in ?? ()
#28 0x00007fffffffeca8 in ?? ()
#29 0x0000000000000000 in ?? ()

@xzyfer
Copy link
Contributor

xzyfer commented Dec 31, 2014

Thanks for that!

It looks like Libsass is returning the correct error

#6 0x00000000007cf481 in Sass::error (msg="2px*px is not a valid CSS value", path="stdin", position=...) at error_handling.cpp:15

Are you sure wellington is dealing with the Sass_Error objects correct?

Do you still get segfaults with this code?

@error("foo");

@drewwells
Copy link
Contributor

Yep, @error parsing works great:

@error("foo");
Error: foo
         stdin:6

On Tue Dec 30 2014 at 6:52:35 PM Michael Mifsud notifications@github.com
wrote:

Thanks for that!

It looks like Libsass is returning the correct error

#6 #6 0x00000000007cf481 in
Sass::error (msg="2px*px is not a valid CSS value", path="stdin",
position=...) at error_handling.cpp:15

Are you sure wellington is dealing with the Sass_Error objects correct?

Do you still get segfaults with this code?

@error("foo");


Reply to this email directly or view it on GitHub
#789 (comment).

@mgreter
Copy link
Contributor Author

mgreter commented Dec 31, 2014

Actually I also still get this crash with perl-libsass. Since everything else is working ok, I guess this is a real problem. And since I can reproduce it I might be able to find out what's the cause for this!
IMO it's not really a regression since it is pretty probable that it never worked anyway!

@mgreter mgreter self-assigned this Dec 31, 2014
@xzyfer
Copy link
Contributor

xzyfer commented Dec 31, 2014

Interesting. Cool sounds like @mgreter is on the case. I've gotten about as far as I can with it. Thanks for all your help @drewwells

@mgreter
Copy link
Contributor Author

mgreter commented Dec 31, 2014

This was a problem/bug with the C API. Should be fixed by #791!
I now also get the error message: 2px*px is not a valid CSS value!

@mgreter mgreter modified the milestones: 3.1, 3.next Dec 31, 2014
@mgreter
Copy link
Contributor Author

mgreter commented Dec 31, 2014

Btw. the different behaviour could be a system specfic one, since it boils down to an unhandled C++ exception in C code. For me it was previously crashing with the message terminate called after throwing an instance of 'Sass::Sass_Error' ...

@xzyfer please review and merge at your discretion 🍷

@drewwells
Copy link
Contributor

working for me too, thanks @mgreter !

Error > stdin:9
2px*px is not a valid CSS value

@mgreter
Copy link
Contributor Author

mgreter commented Dec 31, 2014

👍

@am11
Copy link
Contributor

am11 commented Dec 31, 2014

👍

@xzyfer, got your message on #libsass, with node-sass I tested with this:

require("node-sass").renderSync({data:"div {\
    $a: 1px;\
    $b: 2px;\
    foo: $a * $b;\
}"})

And it returned the error:

{
  "status": 1,
  "file": "stdin",
  "line": 1,
  "column": 27,
  "message": "2px*px is not a valid CSS value"
}

(no crash)

This happened before applying 6729b1a (it is pointing to 420d7fb).

@xzyfer
Copy link
Contributor

xzyfer commented Dec 31, 2014

Thanks @am11. Looks like @mgreter got to the bottom of it.

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

No branches or pull requests

5 participants