Possible thread-safety bug in lemon parser with ParseTrace()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible thread-safety bug in lemon parser with ParseTrace()

Fletcher T. Penney
1)  I hope I am reporting this to the right place.  If not, my apologies.

2) I have been using lemon parsers for a year or more, but am by no
means an export on the lemon source itself.  I did not see this issue
referenced elsewhere, my apologies if I missed it.


I *think* there is a thread-safety issue in the ParseTrace() function:

        void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
          yyTraceFILE = TraceFILE;
          yyTracePrompt = zTracePrompt;
          if( yyTraceFILE==0 ) yyTracePrompt = 0;
          else if( yyTracePrompt==0 ) yyTraceFILE = 0;
        }

It appears that `yyTraceFILE` and `yyTracePrompt` are global variables
that can conceivably be written to simultaneously on two separate
threads.  I suspect the negative effects of this would be low
(overwriting of one prompt with another, and they would likely be
identical strings anyway).


It is detected by Xcode's Thread Sanitizer, and I wanted to report it in
case there was a more untoward effect that I was missing.  If nothing
needs to be done about it, that's fine too.


Thanks!

Fletcher




--
Fletcher T. Penney
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Possible thread-safety bug in lemon parser with ParseTrace()

Richard Hipp-3
On 9/7/17, Fletcher T. Penney <[hidden email]> wrote:
> 1)  I hope I am reporting this to the right place.  If not, my apologies.
>
> 2) I have been using lemon parsers for a year or more, but am by no
> means an export on the lemon source itself.  I did not see this issue
> referenced elsewhere, my apologies if I missed it.
>
>
> I *think* there is a thread-safety issue in the ParseTrace() function:

Yeah, but ParseTrace() is a debugging function, not intended for use
in production systems.  It shouldn't ever be used by multiple threads.
It is not intended to be threadsafe.

If you found a thread-safety issue in the Parse() function, that would
be more interesting!



>
> void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
>  yyTraceFILE = TraceFILE;
>  yyTracePrompt = zTracePrompt;
>  if( yyTraceFILE==0 ) yyTracePrompt = 0;
>  else if( yyTracePrompt==0 ) yyTraceFILE = 0;
> }
>
> It appears that `yyTraceFILE` and `yyTracePrompt` are global variables
> that can conceivably be written to simultaneously on two separate
> threads.  I suspect the negative effects of this would be low
> (overwriting of one prompt with another, and they would likely be
> identical strings anyway).
>
>
> It is detected by Xcode's Thread Sanitizer, and I wanted to report it in
> case there was a more untoward effect that I was missing.  If nothing
> needs to be done about it, that's fine too.
>
>
> Thanks!
>
> Fletcher
>
>
>
>
> --
> Fletcher T. Penney
> [hidden email]
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users