Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pike pike
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 121
    • Issues 121
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • pikelang
  • pikepike
  • Issues
  • #1739
Closed
Open
Created Jun 12, 2001 by Peter Bortas@zinoOwner

compile_string not thread safe

Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=1739

Reported by Marcus Wellhardh wellhard@roxen.com

The following testcase gives some backtraces telling that 'foo' is undefined even if a resolver is used when compiling the string. If the mutex in the code is uncommented no backtrace is returned.

  Thread.Mutex m = Thread.Mutex();

  int threads = 0;

  class Compile
  {
    void go(string txt)
    {
      threads++;
      if (mixed err = catch {
  	for(int i; i < 1000; i++)
  	{
  	  program res;

  	  // Thread.MutexKey l = m->lock();
  	  res = compile_string (
  	    txt, 0,
  	    class (object master) {
  	      mixed resolv (string id, void|string file)
  	      {
  		return "bar";
  	      }
  	    } (master()));
  	  // l = 0;
  	}
      })
  	werror (describe_backtrace (err));
      if (!--threads) exit (0);
    }
  }

  int main()
  {
    for(int t = 0; t < 10; t++)
    {
      Compile compile = Compile();
      thread_create(compile->go, "string f1() { return foo; }");
    }
    return -17;
  }

Output:
 | -:1:'foo' undefined.
 | Compilation failed.
 | /home/wellhard/projects/pike-7.2/build/sunos-5.8-i86pc/master.pike:172:
 |     master()->compile_string("string f1() { return foo;
}",0,gc.pike.Compile.__class_65595_0())
 | gc.pike:23: go("string f1() { return foo; }")
Assignee
Assign to
Time tracking