« first day (277 days earlier)      last day (4674 days later) » 

3:43 AM
Anyone up?
 
Wow you're early!
 
No, not really.
I stayed up.
I shouldn't but...
 
Wow you're late!
 
I found a bug in the mono C# compiler.
I just had to fix it.
 
Did you?
 
3:50 AM
Yep.
It was something easy.
That's why I decided to fix it.
"It will be just half an hour, I think".
And now I'm here.
 
Well I noticed a bug in GCC not long ago and I sure as hell did nothing.
auto const blah[]() { does funny stuff to the front-end apparently.
 
Wow, that's ugly.
 
It's one = away from being correct.
 
Well, my 4.5.2 doesn't choke.
 
Mmh I can't reproduce either.
 
3:53 AM
I get a pretty reasonable error.
 
> internal compiler error: in cp_parser_late_return_type_opt, at cp/parser.c:15562
In my unit test.
 
Hmm, maybe it has something to do with your types, or something.
In isolation, it seems fine.
 
Well the line is actually closer to auto const blah[]() -> ret_t { ... where ret_t is indeed a typedef. Still, can't make it minimal.
I can't say I'm really interested in reproducing the bug.
 
Why are you declaring an array of functions?
 
auto const blah = []() -> ret_t { ...
 
3:56 AM
Aah.
 
No offense intended but that completely broke my flow. I switch to my dev workspace, look at the code and have no idea what I'm looking at.
 
Can I ask you a few questions about C++ design?
 
Well I know what it is but I don't know why it's open.
Shoot away!
 
Ok, I think I might be better off writing an operator*= in terms of operator* contrary to the usual.
Because I'll have to make a copy in operator*= anyways.
Well, at least, I think I have to. I'm doing matrix multiplication.
Am I shooting my foot or something?
 
(I may shoot back a question myself later or at some other time)
 
3:59 AM
No problem. I don't guarantee any answers though.
:)
 
Because you're writing two operators?
Depends on how many tricks you're doing I suppose.
 
Well, usually, I just write operator*= and then operator* is just return lhs *= rhs;, because I pass lhs by value.
 
I.e. YAGNI suggests to write the canonical operator*= and come back rewrite it if needed.
Gah.
> Ok, I think I might be better off writing an operator*= in terms of operator* contrary to the usual.
That doesn't seem contrary to the usual then.
 
In this case, I'll need a copy in operator*=. I'm thinking of writing *= as return *this = *this * rhs;.
 
(I can't tell left from right at this hour.)
Let's make some terminology clear; normally which is the one with the implementation, compound assign or the binary operator?
 
4:04 AM
Compound assign.
 
3 mins ago, by Martinho Fernandes
Well, usually, I just write operator*= and then operator* is just return lhs *= rhs;, because I pass lhs by value.
Right.
 
(It's horrible, my brain is gone.)
 
Oh, sorry about that. I didn't know I had that effect on people :)
 
Nah, flaky sleep pattern these days.
 
4:06 AM
What I'm thinking of doing for the matrices is: ideone.com/JL7L2
 
And the reason is that if you were to implement in terms of *= is that a copy would happen in that very implementation.
 
No, it's because I can't implement *= without copies.
Yes, what you said.
 
Okay.
Well, I don't think the copy makes the real difference.
I think whichever of the two allows for a more expressive implementation is best.
If there is a difference, of course; I don't really know.
 
Oh, well, in that case, I think I'll probably go with the usual scheme.
 
I tend to like implementing inside of op= because the lhs is sort of 'private'.
i.e. no worrying about the symmetry or some such.
 
4:13 AM
Ok, thanks.
 
A simpler topic than what I originally wanted: I'm writing a hierarchy of exceptions for my lua stuff
 
Lua has exceptions?
 
One type for the exceptions 'inside' Lua itself (e.g. v = "mismatched quote'), and one type for the 'meta-'errors, e.g. lua_pcall failed or something.
What to name them?
lua_error would make sense for the base.
lua_scripting_error and lua_runtime_error?
Second one is really vague.
 
Yeah.
lua_script_error and lua_engine_error?
Or whatever is the correct terminology for the lua thingy instead of engine.
 
The distinction is actually quite useful, I had only a lua_error before. It got weird once I allowed the scripts to call some C++ code, which would throw a C++ exception caught by luabind translated to a lua_error and something was lost in translation.
i.e. couldn't tell if the scripts had a mistake or the C++ code.
Now I'll be able to distinguish!
 
4:17 AM
That's a big advantage.
 
@MartinhoFernandes Funny stuff, if I plug luajit in suddenly I have an extremely awesome JIT interpreter.
lua_script_error and lua_interpreter_error mmh
 
Oh, lua_interpreter_error sounds good.
 
I don't know I think I prefer engine better.
i.e. the error is not necessarily from a lua[L]_* function.
 
Hmm.
So the error can come from where instead?
Your glue code?
Ugh, the Portuguese docs for Lua are Brazilian. I can't read that.
switches to English
 
@MartinhoFernandes Yes.
 
4:23 AM
Then, yeah, interpreter kinda gives the wrong idea.
 
engine as a catch-all for the interpreter + whatever I build around it seems okay.
 
Well, go with it :)
 
I'm on it.
Boost.Exception is oh-so-convenient.
struct lua_engine_error: virtual lua_error {};
Done!
 
I'm starting to get the impression I'm not using enough of Boost.
 
It has to serve your purposes though.
 
4:27 AM
Yeah, of course. It's just that it seems to touch everywhere.
 
(And the lua_scripting_error has stuff in it because I want the invariant of always having an error message in it.)
i.e. since lua -e script pretty much guarantees an error message I want that message when doing lua.run(script) !
 
You can always default to "Success" ;)
 
So that I can get a spot on the daily WTF, sure!
 
Well, actually I ran across "Error: success" many times before.
 
I'm tempted by lua_script_error instead of lua_scripting_error; related type synonym lua_script_message seems more apt (apter?).
also it makes lua_engine_ and lua_script lines up.
 
4:31 AM
I concur. (And I think it's apter. Unless there's an exception for this one)
 
'apter' seems to exist but I get google hits for "more apt". I suspect I've seen it before.
In fact the definition of 'apter' is:
> comparative form of apt: more apt
I don't think the definition of 'faster' is "more fast"...
 
WTF, when I typed define:foo Google used to show a bunch of definitions.
Now it just searches of that.
 
It works for me.
'apter' appears as the comparative, not "more apt"
Eh I get "comparative apter or more apt" from another source.
Good enough.
 
Natural languages.
There's no spec.
You just wing it.
And then someone complains you didn't follow the spec.
 
I didn't realize how many different kinds of electrical plugs/outlets/sockets there were until I looked up some detail.
And IIRC that was just for Europe.
Uh oh.
Assume a class hierarchy A > B > C where C is most derived.
There is a virtual function named what (for illustrative purposes only) in the base class (and consequently in the whole hierarchy).
So I'm writing C
 
4:45 AM
No, you're writing C++ :P
Do go on.
 
And I may or may have not a very nice return value for overriding C::what.
What if the nice return value is not available? Can I check the second-most derived implementation? What happens if I call B::what?
 
You get the return value B::what provides?
 
In other words, in the middle of a class hierarchy, if a member is not overriden what do I end up calling if the call is qualified?
 
Oh, there's no B::what?
 
Well, an override anyway.
 
4:47 AM
digs up the FDIS
 
The call is always valid, but I don't know where the call is dispatched according to the rules.
> Explicit qualification with the scope operator (5.1) suppresses the virtual call mechanism.
So I guess if I call B::what inside C::what there is simply no reason that I recursively call C::what.
 
That guarantees C::what doesn't get called.
 
Very good!
 
Does it mean it checks up the hierarchy?
This final thing I see here, is new in C++11, right?
 
Yep, as is override.
 
4:55 AM
I can't find a guarantee that it calls A::what.
(But maybe I'm not checking enough.)
 
Me neither tbh.
I simply didn't bother beyond the above quote.
 
Well, calling A::what is the only thing that makes sense.
Or UB.
But I'd find that stupid for something like this.
 
Me too.
> Segmentation fault
So much for my hierarchy!
 
Hah. valgrind it.
 
Why not gdb?
 
5:00 AM
It probably works too.
I tend to just $ valgrind !! whenever I see segfault on the screen.
It's reflexive now.
 
fatal error in "annex::maybe_throw<annex::lua::value_type> {anonymous}::execute(lua_State*, const char*, const value_type&, const maybe_object&)": std::exception: [string "return '"]:1: unfinished string near '<eof>'
Seems to work fine in the unit test but segfault as a library. Not that kind of scary stuff again :(
Oh wait my makefile is stupid and has no dependency detection.
 
Oh, well.
 
Aaaaand still a segfault.
 
Can't you coerce gdb to give you more info?
 
I'm exploring the stack
I see the error message already.
Uh oh, seems like it's in the std::exception_ptr stuff.
 
5:09 AM
It's probably your code feeding it bad data.
 
More precisely, in std::copy_exception (which is std::make_exception in the FDIS).
> $5 = {<annex::lua_error> = {<annex::exception> = {<boost::exception> = {_vptr.exception = 0x7ffff7ff73d0, data_ = {px_ = 0x43ce40}, throw_function_ = 0x7ffff7fe3a20 "annex::maybe_throw<annex::lua::value_type> {anonymous}::execute(lua_State*, const char*, const value_type&, const maybe_object&)", throw_file_ = 0x7ffff7fe2fb0 "~/annex/src/luafusion.cpp", throw_line_ = 27}, <std::exception> = {<No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}
Seems like I'm feeding it good data to me!
 
See what valgrind says.
 
Well I'm not done yet with gdb.
Although to be honest the error is on line throw __ex; where __ex is the quote above.
Waaaiiiit a minute
The name in the FDIS is actually std::make_exception_ptr and is right below std::copy_exception in the libstdc++ source.
Let's try this.
 
Hmm.
Dammit, this test suite takes forever to run.
 
Meh it delegates to copy_exception.
... by making a copy? How stupid is that?
 
5:16 AM
Probably won't solve the problem, then.
 
Yeah.
I had a plan B all along however
s/std::exception_ptr/boost::exception_ptr/g
s/std::make_exception_ptr/boost::copy_exception/g
 
:)
Now, let's see if it's really the stdlib.
 
Also same treatment for rethrow_exception
Oh the huge manatee.
Segfault again.
 
See, it's your code.
:P
Oh, great, the Makefile calls configure, and then make.
 
Same situation, segfault on throwing.
I get these all the time and the worst thing is I never remember how I fixed the last one.
 
5:24 AM
13 mins ago, by Martinho Fernandes
See what valgrind says.
I'm stubborn.
And I haven't slept.
 
Huh it's been long. What do I pass as argument? I have to pick the tool and the warning level right?
 
For this kind of thing $ valgrind prog should work.
If the info is not enough, $ valgrind --leak-check=full prog
But that often spams you, so I tend to run the basic one first.
 
> valgrind: m_debuginfo/readdwarf.c:2338 (copy_convert_CfiExpr_tree): Assertion 'srcix >= 0 && srcix < VG_(sizeXA)(srcxa)' failed.
 
I'd highly recommend passing the output of valgrind to a file and browsing that later
 
Is that significant?
Or did I just break valgrind?
 
5:26 AM
it will probably be pretty wordy either way unless it's a tiny program
 
Does it say that the impossible happened?
 
No. But the output is actually on stderr, so I guess it's bad.
 
@LucDanton Did you compile with debugger info included?
 
@Josh Always.
 
@LucDanton Try it without.
(I'm just curious if the new debug symbols for c++11 are throwing it off)
 
5:30 AM
Do you remember when I said
1 min ago, by Luc Danton
@Josh Always.
Well I lied.
Apparently in the transition to using a Makefile I forgot the flag.
 
Mmmh it's there so I guess I can write a Makefile better than I'd expect.
 
FWIW, I believe some basic DWARF info is compiled in even if you don't include the -g...so perhaps the incomplete info throws of Valgrind?
 
Same thing without -g
@Josh And that seems to be the assertion down to the line number.
 
Just a side note - it's seems kind of unnecessary at first, but I'd really like to plug cmake unless you have a really trivial makefile
 
5:33 AM
There's no other output?
 
@Josh ATM It's a one-file pet project which uses some of my stuff as a library. The library doesn't use a Makefile but I do have to transition to a decent build system.
@MartinhoFernandes Well it is Valgrind so the actual output is long.
 
@LucDanton cool
Nothing useful at all from the stack frame?
 
@Josh The segfault happens when an exception is thrown.
Disclaimer: using bleeding edge GCC 4.7 snapshot with C++0x code.
 
@LucDanton Ok - and then it bubbles up to the top?
 
It breaks every other week.
 
5:38 AM
Have you tried catch throw?
 
@Josh Nope, throw __ex; on next to last frame, then it's a frame I can't see.
That's how I get there yes.
 
erm
that might not be the right syntax
it is - nm
 
> Catchpoint 1 (exception thrown), 0x00007ffff6f921e0 in __cxa_throw () from /usr/lib/gcc-snapshot/lib/libstdc++.so.6
Last frame.
 
I remember setting a breakpoint on of the standard lib's throw functions too at somepoint... I think it allowed me to see the whole call stack
I'd have to look up how I did it; don't remember the specifics
 
Honestly last week's snapshot simply refused to compile some stuff unless I radically removed most of the object files.
In isolation it accepted each TU, and linked.
It's just that all together welp it gave up.
 
5:41 AM
Your code doesn't compile with a more stable version?
 
Haha no.
I'll try.
Well, overload resolution fail. I think.
(At least it doesn't seem able to handle my make_unique wrapper.)
 
ah
try setting a breakpoint on __cxa_throw
 
Okay.
 
that will break right before entering the exception, showing you the whole frame
 
I don't have it.
Well wait.
What do you mean, the whole frame?
 
5:46 AM
Well, all the way up the stack
 
I had that one before though
 
sorry, not just the "whole current frame" I worded that poorly
 
I don't have much to go with too -- the disassembly.
Let's check. I'm on 0x00007ffff6f921e0
 
So, the point at which it throws the exception is in code you don't have symbols/source for?
 
catch throw ends up in the same exact spot.
@Josh Yep.
Well no.
The code that throws is a standard header.
(or Boost right now)
But right after throw __ex; or whatever the boost version is
then __cxa_throw is called, which is part of the runtime AFAIK.
I haven't tried stepping through the disassembly, I'll try that.
 
5:50 AM
Yeah, __cxa_throw is in libstdc++ iirc
I can try to help you with the dissasambler, if you would like
 
Do you want the dump?
 
sure
 
Dump of assembler code for function __cxa_throw:
   0x00007ffff6f921e0 <+0>:	mov    0x2357d9(%rip),%rax        # 0x7ffff71c79c0
   0x00007ffff6f921e7 <+7>:	push   %rbx
   0x00007ffff6f921e8 <+8>:	lea    -0x20(%rdi),%rbx
   0x00007ffff6f921ec <+12>:	mov    %rsi,-0x70(%rdi)
=> 0x00007ffff6f921f0 <+16>:	mov    %rdx,-0x68(%rdi)
   0x00007ffff6f921f4 <+20>:	movl   $0x1,-0x80(%rdi)
   0x00007ffff6f921fb <+27>:	mov    (%rax),%rax
   0x00007ffff6f921fe <+30>:	mov    %rax,-0x60(%rdi)
   0x00007ffff6f92202 <+34>:	mov    0x2352e7(%rip),%rax        # 0x7ffff71c74f0
 
I can't make any gaurantees though, especially since I don't know c++11 :(
 
As you can see I've started stepping
 
5:52 AM
this is 64bit
 
That would be correct.
 
%rip, lol.
 
I don't see the prologue or epilogue - this is just an arbitrary section
 
I can try to compile in 32 bit.
Let's do that.
 
I do know 32 bit far better :)
(In fact, I know 16bit better than 64...)
 
5:54 AM
egad
I simply don't have the boost libraries etc in 32 bit though.
 
hmm
ok
 
Remembered when I mentioned I'm using a bleeding edge snapshot?
I'm also using ld.gold, I think I should mention that.
 
In 32 bit/g++, the calling convention should be thiscall
I don't know how the stack frame setup transfers over to 64 bit
Normally the ECX reg is used for the this - but since you have extra registers here I don't know if that is still true.
 
Would this & Co really apply to __cxa_throw though?
 
I don't know.
 
5:58 AM
thiscall is nearly identical to cdecl in GCC.
this goes on the stack.
 
I guess not, actually, since that is a C function call
 
Oh hey. Nevermind.
 
It's MSVC that uses ECX.
 

« first day (277 days earlier)      last day (4674 days later) »