FINAL EDIT: I have made clear and simplified this crazy question right into a new question, therefore we can close this Q or whatever is essential to measure the level resolved. Many thanks!

NEW:

Do you know me your opinion of the, and perhaps try to recreate it:

Presently, the $publish->post_content variable consists of:

"before <img src="/path/to/valid_img.gif" /> after"

This code placed towards the top of the theme header.php...

------ Code --------
    1: $str = $post->post_content;
    2: assert( isset( $str ) );
    3: assert( is_string( $str ) );
    4: echo $str;
    5: $str = 'before <img src="/path/to/nonexistant.gif" /> after';
    6: assert( isset( $str ) );
    7: echo $str;
--------------------

Results this...

------ Output ------
before <img src="/path/to/valid_img.gif" /> after
before <img src="/path/to/nonexistant.gif" /> after
--------------------

With one of these alerts...

--- PHP Warnings ---
PHP Warning:  assert() [<a href='function.assert'>function.assert</a>]: Assertion
failed in /path/to/header.php on line 2
PHP Warning:  assert() [<a href='function.assert'>function.assert</a>]: Assertion
failed in /path/to/header.php on line 3
--------------------

Why would line 4 correctly echo the $str if assert() fails two times after i KNOW 100% it will succeed?

Exactly what does a damaged image src have related to setting or unsetting the variable $str? WordPress bug/oddity?

The crazy part...

When lines 5-7 are said out, thus getting rid of the nonexistant.presen, the assert() warning doesn't appear and also the output STILL correctly produces this...

------ Output ------
before <img src="/path/to/valid_img.gif" /> after
--------------------

Any chance you are able to reproduce this and let me know what you believe? I am a new comer to PHP, but I am confident this really is crazyness. :)

OLD:

I am relatively recent to PHP and that i have this code:

$str = $post->post_content; // hi -- [hw] -- bye <img src="foobar.png" />
$str = core_wp( 'foo_shortcode', $str );
echo $str; // return $str; produces the same warning message
// If there is no echo or return, the warning message is not produced.
// The warning disappears when I statically set (as object) the initial $str to
// "hi -- [hw] -- bye <img src="foobar.png" />".

After I run the above mentioned code, it really works fine (foo-shortcode does it's job). The output is:

hi -- Hello World -- bye <img src="foobar.png" />

However always understand this warning message, saying that foo-shortcode appears to become attempting to run itself again, except the next time around, $str doesn't exist.

And also the catch... I only understand this warning message when $str consists of an HTML img tag pointing to some non-existant src.

PHP Warning:  Missing argument 1 for foo_shortcode() in ...

Here is core-wordpress() and foo-shortcode():

function core_wp( $function, $a = NULL, $b = NULL )
{
    $wrap = array
    (
    	'foo_shortcode'				=> 'foo_shortcode',
    );
    $args = array();
    if ( isset( $a ) ) $args[] = $a;
    if ( isset( $b ) ) $args[] = $b;

    return call_user_func_array( $wrap[ $function ], $args );
}

function foo_shortcode( $content ) {
    return str_replace( '[hw]', 'Hello World', $content );
}

First, why would the code work fine, after which concurrently appear to try and run itself again?

And concerning the $str that contains an invalid img, I suspect it has something related to the way in which WordPress creates $publish->post_content.

EDIT 1 (Weds, This summer 22 @ 8:55am)

I added error-log() per your instructions such as this:

error_log( 'done1' );
$str = $post->post_content;
error_log( 'done2' );
$str = core_wp( 'foo_shortcode', $str );
error_log( 'done3' );

... also it created this during my error log:

[22-Jul-2009 08:52:49] done1
[22-Jul-2009 08:52:49] done2
[22-Jul-2009 08:52:49] PHP Warning:  Missing argument 1 for foo_shortcode() in
/home/path/to/header.php on line 23
[22-Jul-2009 08:52:49] done3

... and also the output delivered to the browser (properly) was:

hi -- Hello World -- bye <img src="foobar.png" />

... however the warning message was still being created.

EDIT 2 (Weds, This summer 22 @ 9:18am)

Then i attempted this assertion:

59: $str = $post->post_content;
60: assert( isset( $str ) );
61: $str = core_wp( 'foo_shortcode', $str );
62: assert( isset( $str ) );

... and also the PHP log shows:

[22-Jul-2009 09:16:55] PHP Warning:  assert() [<a 
href='function.assert'>function.assert</a>]: Assertion failed in
/home/path/to/header.php on line 60
[22-Jul-2009 09:16:55] PHP Warning:  Missing argument 1 for foo_shortcode() in
/home/path/to/header.php on line 23

... however, the output is correct, the warning continues to be released.

It appears in my experience that PHP is initially not setting $str = $publish->post-content, it runs core-wordpress( 'foo-shortcode', $str ) and states to itself "oh! I really should set $str = $publish->post-content..." dates back and sets it, after which results the right data.