[uClibc] Php 4.3.1 with uclibc 0.9.19 -- 'input in flex scanner failed' issue

Manuel Novoa III mjn3 at codepoet.org
Mon Jun 23 23:38:04 UTC 2003


On Mon, Jun 23, 2003 at 12:21:16PM -0700, joe at cityofsanmateo.org wrote:
> its a simple fix actually, 
> 
> in $php-source-dir /Zend/zend_language_scanner.c 
> 
...
> 
> change this line:
>         else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
> to
>         else if ( ((result = fread( buf, 1, max_size, yyin )) <0) \
> 
> and recompile, it should take care of your problem,

You're kidding, right?  fread returns a size_t which is an 'unsigned"
type.  It will never return a value < 0.  All your change does is
remove an error check.

> im not sure what the cause is except that uclibc behavior
> is different from glibc

Right reason, but wrong function.  The problem is that php calls
fflush() on the opened stream prior to the fread() call.  According
to ANSI/ISO C99, calling fflush() on a readonly or currently reading
stream is _undefined_behavior_.  In uClibc, I chose to set the stream's
error indicator, set errno, and return failure.  So, when php calls
ferror() because fread() returned 0, it sees that the stream is in
an error state and assumes it was the read that failed.

In the interest of compatibility, I will make fflush() behavior in
this situation a build-time config option.  But relying on undefined
behavior is a bug.

Manuel


More information about the uClibc mailing list