Language:
switch to room list switch to menu My folders
Go to page: [1] 2 3 4 5 ... Last
↑↑↑ Old messages ↑↑↑            ↓↓↓ New messages ↓↓↓
[#] Fri Jun 01 2012 21:15:38 EDT from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Wow. Just ... wow.

$ php
<?php

function foo() {
foo();
}

foo();
?>
Segmentation fault

If you accidentally perform an infinite recursion in PHP, it doesn't throw
an exception, it doesn't tell you it ran out of stack space, it just SEGFAULTS
THE INTERPRETER.

I've been banging my head on the keyboard for a week trying to figure out why
my Z-Push backend isn't allowing attachments to be downloaded, only to discover
tonight that I've been crashing the interpreter.

So much for the brave new world of managed code. At least I can open my C
programs in a debugger and immediately find out what went wrong.

[#] Fri Jun 01 2012 23:04:26 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

LoanSharks-MacBook-Pro:~ ls$ php
<?php

function foo() {
foo();
}

foo();
?>
^D
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 523800 bytes) in - on line 4
LoanSharks-MacBook-Pro:~ ls$ php --version
PHP 5.3.8 (cli) (built: Dec 5 2011 21:24:09)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

All php.ini at default settings for OS X 10.6

[#] Sun Jun 03 2012 21:56:11 EDT from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I've heard about it failing that way too. What I really need is for it to tell me what I screwed up, and print a stack trace as is commonly done on computers that are not older than I am. The reason I'm at this point in the first place is because I did some Googling on PHP segfaults and eventually landed on a web page that mentions "when the PHP interpreter segfaults it's usually because of infinite recursion."

There's something called "xdebug" that I can supposedly add to my PHP to help out with this. I'm going to give it a try.

[#] Mon Jun 04 2012 09:00:10 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

RTOL as far as I'm concerned. PHP was not designed; it's actually an amalgamation of warts. It has warts growing on other warts.

;)

[#] Mon Jun 04 2012 13:20:08 EDT from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

I'm not using PHP by choice; it's an existing mobile sync framework to which I'm adding my own backend. I would not have chosen PHP. (No surprise there, I write everything in C, but even if managed code were a given I probably would have chosen some other language.)

[#] Fri Jun 08 2012 15:51:37 EDT from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

One sign that you're a good programmer is that you don't put double dots into hostnames. :)

[#] Fri Jun 08 2012 16:10:59 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

yea, thats what happenes when you click codeproject links ;-)

fancily some proxies/dnses like it, some don't...



[#] Mon Jun 11 2012 12:59:08 EDT from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Decades later, I still find the expression "x = 1 - x" to flip the value of a boolean represented as an integer to be wonderfully clever. Call me a simpleton but there's just something attractively elegant about it.

[#] Mon Jun 11 2012 13:18:11 EDT from Spell Binder @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Correct me if I'm wrong, but wouldn't that expression only work when x is either 0 or 1? It's been a while since I've programmed in C, but I vaguely remember that zero indicates false, but any non-zero value indicates true.
If so, then the following code wouldn't work.

int x = 3;
x = 1 - x;

May not be as clever, but seems to me to be far more reliable to stick with x = !x.
Spell

[#] Mon Jun 11 2012 14:10:36 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

spel, you're totaly right.

and there is a good reason for ΅true" == !0

most processor architectures know something expressed in assembler like this:

jnz <jump mark> or jz <jump mark>

-> Jump if (not) Zero; a register can be added in more modern processor architectures.

therefore: yes, its a good idea not to take IGs hack.

depending on the datatype you can even get more bad effects:

In corba, a boolean value is a byte value; while most c-compiler specific booleans are simply ints.

so if you true is above 255, it will suddenly become false in the corba layer.



[#] Mon Jun 11 2012 15:57:16 EDT from kc5tja @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

It fails with languages that represent true
as all bits set too.

CORBA's representation is true only over the
wire. When unmarshalled, the proxy or stub
should normalize the value. When
marshalling, true values should be sent as 1,
and only 1.

If your IDL compiler doesn't ensure this,
then it's technically broken, and should have
a bug report filed against it.

[#] Mon Jun 11 2012 16:55:15 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

 

Mon Jun 11 2012 15:57:16 EDT from kc5tja @ Uncensored
It fails with languages that represent true
as all bits set too.

CORBA's representation is true only over the
wire. When unmarshalled, the proxy or stub
should normalize the value. When
marshalling, true values should be sent as 1,
and only 1.

If your IDL compiler doesn't ensure this,
then it's technically broken, and should have
a bug report filed against it.

the idl compiler doesn't have to be in the game here; since c doesn't specify a type for boolean, while corba does.

so if you call your corba stub with a value > 255 (and all 8 lower bits 0) the c-compilers "convert" the int to the byte and throw away wats not there.



[#] Tue Jun 12 2012 13:54:05 EDT from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Damn buncha pedants. Yes I'm talking about a variable within a single function that has a variable that toggles back and forth between 1 and 0.

And who said I'm working in C ? This is a PHP program.

[#] Tue Jun 12 2012 16:47:51 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

you're posting in the programming room, not the scripting room ;-P



[#] Tue Jun 12 2012 16:49:04 EDT from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

 

Tue Jun 12 2012 16:47:51 EDT from dothebart @ Uncensored

you're posting in the programming room, not the scripting room ;-P



and the last time I did php, it hat $ in them.



[#] Tue Jun 12 2012 17:47:09 EDT from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


Bwahaha... no sigils!

[#] Wed Jun 13 2012 17:04:04 EDT from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

you're posting in the programming room, not the scripting room ;-P

PHP compiles into bytecode at runtime so it's not a scripting language. That's why comments don't slow the system down like they do in BASIC. :)

[#] Thu Jun 14 2012 11:57:08 EDT from ax25 @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

PHP?  Well, all bets are off then.

Tue Jun 12 2012 01:54:05 PM EDT from IGnatius T Foobar @ Uncensored
Damn buncha pedants. Yes I'm talking about a variable within a single function that has a variable that toggles back and forth between 1 and 0.

And who said I'm working in C ? This is a PHP program.

 



[#] Fri Jun 15 2012 10:23:09 EDT from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Yes I know, given a choice I would have continued my unorthodox but awesome usual practice of writing everything in C, but in this case I'm writing a module that attaches to someone else's project.

Go to page: [1] 2 3 4 5 ... Last