Stratego/XT JIRA  History | Log In     View a printable version of the current page. Get help!  
Issue Details (XML | Word)

Key: STR-583
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Martin Bravenboer
Reporter: Martin Bravenboer
Votes: 0
Watchers: 0
Operations

Clone this issue
Create sub-task
If you were logged in you would be able to see more operations.
Stratego/XT

i686-apple-darwin: stratego tools that fork are signaled

Created: 2006-06-03 17:42   Updated: 2008-03-31 20:46
Component/s: autoxt
Affects Version/s: 0.16 (Stratego Core Compiler)
Fix Version/s: 0.17

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
File Attachments: 1. Text File foo.c (0.6 kb)



 Description  « Hide
pack-sdf:

opt/bin/pack-sdf -i TIL.sdf -o TIL.def --dep TIL.dep
  including ./TIL.sdf
[ pack-sdf | warning ] process signaled: USR1 (10): User-defined signal 1

parse-stratego has same problem:

minipowerrrr:~/tmp/strategoxt-0.17M1pre15325 martin$ /opt/bin/parse-stratego -i foo.str
[ parse-stratego | warning ] process signaled: USR1 (10): User-defined signal 1

Strange enough, parse-stratego fails, but sglri succeeds. Investigating this issue.


 All   Comments   Work Log   Change History      Sort Order:
Martin Bravenboer [2006-06-03 22:06]
The problem has been reproduced in a smaller setting. The signal is caused by the invocation of a nested function after a fork. The child process invokes a nested function defined by the parent process and fails.

It's not yet clear if this is a problem with recent GCC's on all platforms. At least it is not Apple GCC 4.0.1 specific: FSF GCC 4.0.3 produces the same problem on i686-apple-darwin.

The test program:
--------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>

void f(int x);
void g(int arg(int));
void h(int arg(int));

int main(int argc, char* argv[])
{
  f(2);
  return 0;
}

void f(int x)
{
  auto int nested(int y);
  int nested(int y)
  {
    return x + y;
  }
  
  g(nested);
}

void g(int arg(int))
{
  pid_t pid = fork();
   
  if(pid == 0)
  {
    int x = arg(3);
fprintf(stderr, "x = %d \n", x);
exit(0);
  }
  else
  {
    int status;
waitpid(pid, &status, 0);
fprintf(stderr, "exit? %d \n", WIFEXITED(status) ? WEXITSTATUS(status) : -1);
fprintf(stderr, "signal? %d \n", WIFSIGNALED(status) ? WTERMSIG(status) : -1);
  }
}
-------------------------------

This should print:
exit? 0
signal? -1

But on the Mac/Intel it prints:
exit? -1
signal? 10

Martin Bravenboer [2006-06-03 22:11]
4.0.2 on linux works fine.

Martin Bravenboer [2006-06-03 22:20]
Simplifcation of the test program is attached.

It turns out that the nested function needs to use a variable from the outer function, otherwise the process is not signaled.

Martin Bravenboer [2006-08-10 20:58]
STR-583: Reverted the temorary work-arounds, which are no longer necessary now we have a new compilation scheme without nested functions.