public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Basile Starynkevitch <basile@starynkevitch.net>
Cc: jit@gcc.gnu.org
Subject: Re: outputs of GCC JIT?
Date: Thu, 01 Jan 2015 00:00:00 -0000	[thread overview]
Message-ID: <1436449490.24803.125.camel@surprise> (raw)
In-Reply-To: <20150709104325.GA789@ovh.starynkevitch.net>

On Thu, 2015-07-09 at 12:43 +0200, Basile Starynkevitch wrote:
> Hello All,
> 
> In my partial understanding, gccjit is outputing either error messages or logging.
> 
> The log file can be set with  gcc_jit_context_set_logfile
> 
> But what about the error messages?
> 
> Perhaps we are lacking some 
> 
>    gcc_jit_context_set_errorfile(gcc_jit_context*ctxt, FILE*errfile, int flags);
> 
> Can we be sure that GCCJIT does never write to stdout or stderr?
> 
> A typical usecase where we don't want that is some CGI or FastCGI web-application...
> (which reserves stdout & stderr for their own use).

In theory an error should not occur; it's fatal to the gcc_jit_context
*, no further compilation can happen on that context.

I guess it could be handy to be able to send the error messages
somewhere other than stderr, for flexibility if nothing else.  A service
that logs to its own logfile, or to syslog might want to send error
messages there, and a FILE * might not be generic enough.

Maybe the API could look like this:

typedef void
(*gcc_jit_error_handler) (gcc_jit_context *ctxt,
                          gcc_jit_location *loc,
                          const char *msg,
	                   void *user_data);

extern void
gcc_jit_context_set_error_handler (gcc_jit_context *ctxt,
                                   gcc_jit_error_handler callback,
                                   void *user_data);

with a NULL callback meaning "default behavior", or maybe also exposing:

extern void
gcc_jit_default_error_handler (gcc_jit_context *ctxt,
                               gcc_jit_location *loc,
                               const char *msg,
	                        void *user_data);
	                            
This has the side-benefit of allowing users to easily put a breakpoint
on this callback in a debugger.

(I wondered also if there's a security risk in having messages go to
stderr for CGI scripts, but I think that any place where an attacker
could try to discern something from the error messages is also likely
somewhere where the attacker is already able to inject arbitrary machine
code, so it's already "game over" at that point).

      reply	other threads:[~2015-07-09 13:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-01  0:00 Basile Starynkevitch
2015-01-01  0:00 ` David Malcolm [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1436449490.24803.125.camel@surprise \
    --to=dmalcolm@redhat.com \
    --cc=basile@starynkevitch.net \
    --cc=jit@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).