in reply to Re^3: Inline C: using stderr segfaults?
in thread Inline C: using stderr segfaults?

There does appear to be a bug in the impementation of fprintf(). Note how in the output of the following code, test() prints the value of stderr when fetched via the Perl macros, and directly from the OS and gets the same value. But then in test2(), when it tries to pass & use the directly accessed value with fprintf() it does in exactly the same way and at exactly the same point as when using it via the Perl macro.

However, when I pass the Perl macro derived value to vfprintf() in eprintf() it works fine. Indicative of something, though I'm not sure exactly what :)

#! perl -slw use strict; #use Inline 'FORCE'; use Inline C => 'DATA', NAME => 'IC_junk1', CLEAN_AFTER_BUILD => 0; test( 'fred' ); test2( 'fred' ); __DATA__ __C__ #include <stdio.h> #include <stdarg.h> void eprintf (const char *template, ...) { va_list ap; va_start( ap, template ); vfprintf( stderr, template, ap ); va_end( ap ); } void test ( char* text ) { printf( "Got:'%s'\n", text ); printf( "stderr via PerlIO macro: %x\n", stderr ); printf( "stderr via Win32_stderr: %x\n", win32_stderr() ); } void test2 ( char* text ) { // eprintf( "Get:'%s'\n", text ); fprintf( win32_stderr(), "Get:'%s'\n", text ); } /* Outputs: C:\test>IC-junk1.pl Got:'fred' stderr via PerlIO macro: 77c5acc0 stderr via Win32_stderr: 77c5acc0 then segfaults when fprintf( stderr, .... ) is called. */

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."