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

Bug: Segmentation fault accessing macros array #756

Closed
zoziha opened this issue Sep 18, 2022 · 0 comments · Fixed by #762
Closed

Bug: Segmentation fault accessing macros array #756

zoziha opened this issue Sep 18, 2022 · 0 comments · Fixed by #762
Labels
bug Something isn't working

Comments

@zoziha
Copy link
Contributor

zoziha commented Sep 18, 2022

Description

fpm built in release mode will segfault when it encounters the following fpm.toml macro definition:

name = "preprocess_hello"

[preprocess]
cpp.suffixes = ["F90"]

[dependencies]
preprocess_hello_dependency = { path = "../preprocess_hello_dependency" }
>> fpm run --profile release -- build -C ./example_packages/preprocess_hello
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0 0x6066965a
#1 0x605deff3
#2 0xc1c789b1
#3 0xc49f0e0f
#4 0xc6c1235e
#5 0xc6bc14a3
#6 0xc6c10e8d
#7 0xc1b395d2
#8 0xc1b49da4
#9 0xc1b31c57
#10 0xc1c7a28f
#11 0xc1b313ad
#12 0xc1b314e5
#13 0xc6457033
#14 0xc6bc26a0
#15 0xffffffff
<ERROR> Execution failed for object " fpm.exe "
<ERROR>*cmd_run*:stopping due to failed executions
STOP 1

After debugging, I found that the segfault appears at:

fpm/src/fpm.f90

Line 119 in e2a8218

model%packages(i)%macros = dependency%preprocess(j)%macros

Because macros are not actually allocated, but are accessed, a segmentation fault occurs.

Expected Behaviour

fpm works fine.

Version of fpm

latest commit, e2a8218

Platform and Architecture

Windows

Additional Information

I found that this segfault often occurs when reading the array member of fpm.toml, sometimes this toml array member is not provided, so that the allocatable array is not allocated, but we think it is allocated, the reason may be that the get_list routine is not reasonable enough,(?) I think when the toml array is accessed, even if the toml array doesn't exist, changes need to be made for the allocatable array, such as allocate(array(0)) or a judgment on the result of the toml read.

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant