Am 2016-03-25 15:35, schrieb Georg Mischler:
Moving this to a seperate thread.


The sequence below consistently gives me 703 on Vista, with the only
difference that the DOS box asks for double quotes.

But...

turning up n to values beyond 2000, the MSC binary of rcalc begins to
write(!) some bytes less(!) to stdout. Which obviously falsifies the
result of the chain.

Interesingly, the NREL binary doesn't do that.
Rob mentioned using gcc, so there seems to be a disagreement between
the two compilers as to the semantics of writing to stdout on program
termination.

Going to have some discussion with the debugger on this one.
I'd only be too happy if a simple flush() would solve the problem...

Ah, and first I should probably create a few test cases to cover this
kind of bug.


round two:

I've detected the problem by redirecting the output of rcalc
into a file, which ends up too small.
It always happens when running in bash.
It currently gives the correct output about one time out of
four running in cmd.exe.
When reading from a file instead of through a pipe from cnt,
the output is always correct.
Adding a fflush() doesn't change anyhting, as mentioned the
exit() will do that anyway.
There's no problem when feeding the same data through
call_one() from pyradlib.
Passing in the output of cnt through call_two() currently runs
into a deadlock that I can't quite explain.

It's getting more and more mysterious...

-schorsch


Cheers
-schorsch


I've searched for similar complaints online. In the few instances I've
found, it usually was because a terminating null byte wasn't written
to the receiving buffer for some reason. The purportedly received
garbage data was then simply the previous random contents of that
buffer. That may or may not be the cause here as well.

If there really was an inherent problem with using pipes on Windows,
then I'm sure I would have found a lot more information about it.

Well, in our case, it's not about null bytes not being sent -- it's
about knowing exactly when we've reached end-of-data, which we expect
the system to tell us in some cases.  Radiance's binary formats for
octrees, ambient files, pictures, etc., we know when we've reached EOD
regardless because the file header tells us how much to expect.
However, when we're sending binary streams of floats to rcalc, which
is simply operating on them and counting on the OS to stop sending
data when it's out of data, we run into trouble if the OS doesn't tell
us exactly when the party is over.

I suppose a simple test would be something like:

        cnt 37 | rcalc -of -e '$1=recno' | total -if

This should give us a value of 703, or n*(n+1)/2 for any n (i.e.,
37*(37+1)/2==703).  We could try running the above on a Windows box
with a FAT or ExFAT filesystem to determine if this is a problem or
not.  We should probably try it with some large numbers as well, being
aware that we end on a 128-byte boundary when n is a multiple of 32.

We can also try it while writing with an intermediate file between
rcalc and total, to see if that makes any difference.

--
Georg Mischler  --  simulations developer  --  schorsch at schorsch com
+schorsch.com+  --  lighting design tools  --  http://www.schorsch.com/


_______________________________________________
Radiance-dev mailing list
Radiance-dev@radiance-online.org
http://www.radiance-online.org/mailman/listinfo/radiance-dev

Reply via email to