Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OMP_OFFLOAD_LLVM] Crash due to gbl.ompaccfile is NULL #1398

Open
dmikushin opened this issue Jun 27, 2023 · 4 comments
Open

[OMP_OFFLOAD_LLVM] Crash due to gbl.ompaccfile is NULL #1398

dmikushin opened this issue Jun 27, 2023 · 4 comments

Comments

@dmikushin
Copy link
Contributor

In tools/flang2/flang2exe/llutil.cpp:1707:

1705	#ifdef OMP_OFFLOAD_LLVM
1706	  if(flg.omptarget)
1707	    ll_write_module_header(gbl.ompaccfile, gpu_llvm_module);
1708	#endif

The gbl.ompaccfile value is uninitialized

(gdb) p gbl.ompaccfile
$4 = (FILE *) 0x0
@dmikushin
Copy link
Contributor Author

dmikushin commented Jun 27, 2023

My usecase is:

flang -O2 -fopenmp -fopenmp-targets=x86_64,nvptx64-nvidia-cuda \
    /openmp-offload-example/src/example.f90 \
    -o /openmp-offload-example/build/example

And it crashes because gbl.ompaccfile should be a file handle to gbl.ompaccfilename = "/tmp/example-9be20d-x86_64.ll/tmp/example-9be20d-nvptx64-nvidia-cuda.ll".

This path is obviously invalid, and has been created due to wrong handling of multiple offload targets.

@dmikushin
Copy link
Contributor Author

Here is when the invalid path is being filled into the variable:

Old value = 0x0
New value = 0x7ffcde22b8d1 "/tmp/example-9be20d-x86_64.ll/tmp/example-9be20d-nvptx64-nvidia-cuda.ll"
parse_arguments (parser=0x5595877f4c90, argc=159, argv=0x7ffcde22a718) at tools/flang2/flang2exe/arg_parser.cpp:382
382	tools/flang2/flang2exe/arg_parser.cpp: No such file or directory.
(gdb) up
#1  0x0000559585d71954 in init (argc=159, argv=0x7ffcde22a718) at /classic-flang/src/classic-flang/tools/flang2/flang2exe/main.cpp:663
663	  parse_arguments(arg_parser, argc, argv);

@dmikushin
Copy link
Contributor Author

There is a -fopenmp-targets-asm option in flang2, but it is not exposed to the clang frontend

@bryanpkc
Copy link
Collaborator

@shivaramaarao Can you comment on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants