www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - (linux bug?) why is it that a function must return a value or it seg faults?

reply clayasaurus <clayasaurus_member pathlink.com> writes:
Hello. I'm working on a project with multiple files and all. Here is the code

void logf(...) // this will cause a seg fault
{
// do logging stuff
}

bit logf(...) // this will work just fine
{
// do logging stuff
return true; 
}

I'm wondering why is it that when I use (...) for an argument, I must return a
value or else it segfaults? 
Jul 19 2004
next sibling parent Ant <Ant_member pathlink.com> writes:
In article <cdgn2l$fk1$1 digitaldaemon.com>, clayasaurus says...
Hello. I'm working on a project with multiple files and all. Here is the code

void logf(...) // this will cause a seg fault
{
// do logging stuff
}

bit logf(...) // this will work just fine
{
// do logging stuff
return true; 
}

I'm wondering why is it that when I use (...) for an argument, I must return a
value or else it segfaults? 
oh! that's why! I experienced that and just remove the (...) parameter, changing the API of the thing of course. This is on DUI MessageDialog and nobody notice it. :( Ant
Jul 19 2004
prev sibling next sibling parent reply clayasaurus <clayasaurus_member pathlink.com> writes:
argh! wtf?! 

Ok, now I can use 

void logf(...) fine, however, if i don't pass at least 2 parameters it causes it
to crash. :-|
Jul 19 2004
next sibling parent clayasaurus <clayasaurus_member pathlink.com> writes:
but if i pass two or more arguments into writef than it doesn't crash!
help! these seg-faults are eating away at my sssanityyz ahh! 
Jul 19 2004
prev sibling next sibling parent clayasaurus <clayasaurus_member pathlink.com> writes:
and sometimes I have to pass at least 3 arguments or it causes it to crash. 
Jul 19 2004
prev sibling parent reply clayasaurus <clayasaurus_member pathlink.com> writes:
i found it that it doesn't even seg fault inside the function. 

just the act of passing less than two or three arguments causes it to seg fault.
Jul 19 2004
parent clayasaurus <clayasaurus_member pathlink.com> writes:
a temporary solution is to pass 2 dummy arguments for my function like

void logf(int dummy, int dummy2, ...) 
{
char[] message = stamp(std.utf.toUTF8(formatstring(_arguments, _argptr)));
gLogFile.writeString(message);
}

and it works. however it seems unnecessary and it's ugly. 
I hope there's a better way.
Jul 19 2004
prev sibling parent reply clayasaurus <clayasaurus_member pathlink.com> writes:
Ok, here is something different but I think it is related some how. When I use
writef it crashes, when i use printf it doesn't. 

This must be a bug, right? (see attachment)



begin 0644 bug.d
M+R\ 3D]413H 5&AE(&)U9R!O;FQY('=O<FMS('=H96X ;6%I;BYD(&%N9"!A
M<F=U9FEL92YD(&%R92!P=70 :6X "B\O"0D)<V5P97)A=&4 9FEL97, 86YD
M(&-O;7!I;&5D(&QI:V4 )V1M9"!M86EN+F0 87)G=69I;&4N9"< "B\O"0D)
M06QS;RP 22=M('-U<F4 =W)I=&5F;&X :7, 8V%U<VEN9R!T:&4 8W)A<V  
M8V%U<V4 =VAE;B!)(`HO+PD)"75S92!P<FEN=&8H*2P :70 9&]E<VXG="!C
M<F%S:"X " HO+R!M86EN+F0 +2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+0H*:6UP;W)T(&%R9W5F:6QE
M.PH*:6YT(&UA:6XH8VAA<B!;75M=(&%R9W,I"GL*"6-H87);72!M97-S86=E
M(#T 87)G=6UE;G1S*")B;V( :7, (BP -RP (B!Y96%R<R!O;&0B*3L*"0H)
M=W)I=&5F;&XH;65S<V%G92D[" D*"6%R9W5F:6QE+G5S96%R9W,H*3L +R\ 
M=VEL;"!C<F%S:"!H97)E" D*"7)E='5R;B`P.R` "GT*"B\O(&%R9W5F:6QE
M+F0 +2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2TM+0II;7!O<G0 <W1D+G-T9&EO.PII;7!O<G0 <W1D+F9O<FUA
M=#L*:6UP;W)T('-T9"YU=&8[" ID8VAA<EM=(&9O<FUA='-T<FEN9RA4>7!E
M26YF;UM=(&%R9W5M96YT<RP =F]I9"`J87)G<'1R*2`*>PH*"61C:&%R6UT 
M;65S<V%G92`](&YU;&P[(`H*"79O:60 <'5T8RAD8VAA<B!C*0H)>PH)"6UE
M<W-A9V4 ?CT 8SL " E]" H*"7-T9"YF;W)M870N9&]&;W)M870H)G!U=&,L
M(&%R9W5M96YT<RP 87)G<'1R*3L*" D*"7)E='5R;B!M97-S86=E.R`*?0H*
M8VAA<EM=(&%R9W5M96YT<R N+BXI("\O('1U<FYS(&$ 8G5N8V  ;V8 87)G
M=6UE;G1S(&EN=&\ 82!F;W)M871T960 8VAA<EM=('-T<FEN9PI[" ER971U
M<FX <W1D+G5T9BYT;U541C H9F]R;6%T<W1R:6YG*%]A<F=U;65N=',L(%]A
M<F=P='(I*3L*?0H*=F]I9"!U<V5A<F=S*"XN+BD*>PH)8VAA<EM=(&-R87-H
M86=E(#T 87)G=6UE;G1S*")W:'D :7, ."!S8V%R960 ;V8 -S\ 8F5C875S

:(`H)=W)I=&5F;&XH8W)A<VAA9V4I.R`*?0HE
`
end
Jul 19 2004
parent reply "Walter" <newshound digitalmars.com> writes:
"clayasaurus" <clayasaurus_member pathlink.com> wrote in message
news:cdgrdn$hig$1 digitaldaemon.com...
 Ok, here is something different but I think it is related some how. When I
use
 writef it crashes, when i use printf it doesn't.

 This must be a bug, right? (see attachment)
I can't reproduce the problem with your example.
Jul 23 2004
parent Ant <duitoolkit yahoo.ca> writes:
On Fri, 23 Jul 2004 17:43:20 -0700, Walter wrote:

 
 "clayasaurus" <clayasaurus_member pathlink.com> wrote in message
 news:cdgrdn$hig$1 digitaldaemon.com...
 Ok, here is something different but I think it is related some how. When I
use
 writef it crashes, when i use printf it doesn't.

 This must be a bug, right? (see attachment)
I can't reproduce the problem with your example.
I can't either but I had the same problem, I'll post it if I can reduce it to 10 lines Ant
Jul 23 2004