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

SEGFAULT in p4c-bm2-ss (P4::CallGraph<...>::strongConnect) #185

Closed
cole-barefoot opened this issue Dec 13, 2016 · 9 comments
Closed

SEGFAULT in p4c-bm2-ss (P4::CallGraph<...>::strongConnect) #185

cole-barefoot opened this issue Dec 13, 2016 · 9 comments
Assignees
Labels
bug This behavior is unintended and should be fixed. wontfix This is a problem that will not be fixed.

Comments

@cole-barefoot
Copy link
Contributor

Attempting to compile the attached P4_14 program with p4c-bm2-ss results in a SEGFAULT.

Program: repeater.txt

Command:

./p4c-bm2-ss --p4-14 repeater.txt

Stack trace:

#0  P4::CallGraph<IR::Expression const*>::strongConnect (this=this@entry=0x7fffffffc3f0, node=0xde30a0, helper=..., out=std::vector of length 0, capacity 0) at ../frontends/p4/callGraph.h:335
#1  0x0000000000671214 in sccSort (out=std::vector of length 0, capacity 0, start=<optimized out>, this=0x7fffffffc3f0) at ../frontends/p4/callGraph.h:370
#2  P4V1::ProgramStructure::createDeparser (this=this@entry=0x7fffffffc7c8) at ../frontends/p4/fromv1.0/programStructure.cpp:543
#3  0x00000000006835d3 in P4V1::ProgramStructure::create (this=0x7fffffffc7c8, info=...) at ../frontends/p4/fromv1.0/programStructure.cpp:1912
#4  0x000000000068e354 in P4V1::(anonymous namespace)::Rewriter::preorder (this=0xdabe10, global=0xdb1a00) at ../frontends/p4/fromv1.0/converters.cpp:492
#5  0x00000000006075f7 in IR::V1Program::apply_visitor_preorder (this=0xdb1a00, v=...) at ../ir/ir-inline.h:39
#6  0x0000000000649ccf in Transform::apply_visitor (this=0xdabe10, n=0xdb1460, name=<optimized out>) at ../ir/visitor.cpp:239
#7  0x000000000063b685 in visit (name=0x0, n=<synthetic pointer>, this=0xdabe30) at ../ir/visitor.h:75
#8  IR::Node::apply (this=0xdb1460, v=...) at ../ir/node.cpp:69
#9  0x000000000063c7f2 in PassManager::apply_visitor (this=0x7fffffffc780, program=0xdb1460) at ../ir/pass_manager.cpp:34
#10 0x0000000000502341 in visit (name=0x0, n=<synthetic pointer>, this=0x7fffffffd630) at ../ir/visitor.h:75
#11 parseP4File (options=...) at ../frontends/common/parseInput.cpp:39
#12 0x0000000000405cb2 in main (argc=3, argv=0x7fffffffde58) at ../backends/bmv2/bmv2.cpp:47
@cole-barefoot cole-barefoot added the bug This behavior is unintended and should be fixed. label Dec 13, 2016
@mihaibudiu
Copy link
Contributor

This program #includes a file which is not available. In the absence of this file the program does not crash.

@cole-barefoot
Copy link
Contributor Author

Good catch. It appears the SEGFAULT occurs for unrecognized include files. Changing the include to:

#include "foo.p4"

also triggers the crash.

@mihaibudiu
Copy link
Contributor

Can you assign this bug to @ChrisDodd please?
The compiler should stop with an error from the preprocessor, but it does not.

@mihaibudiu
Copy link
Contributor

Also, the errors from the preprocessor are not relayed to the user - so the user does not know what the problems are.

@ChrisDodd
Copy link
Contributor

This just gives me:

error: Preprocessor returned exit code 256; aborting compilation
error: 1 errors encountered, aborting compilation

which is somewhat unclear (should be copying the preprocessor error message), but not incorrect...

@mihaibudiu
Copy link
Contributor

The fact that the preprocessor error message is not relayed to the user is a bug in itself.
This was introduced when adding 2>/dev/null to the cpp invocation.

@ChrisDodd
Copy link
Contributor

Without the >/dev/null we get spurious warning messages from the preprocessor (sometimes), which cause other problems.

@mihaibudiu
Copy link
Contributor

The problem was with newlines in strings.
Still, probably capturing the stderr of the cpp is necessary.

@mihaibudiu
Copy link
Contributor

I believe that this issue has been solved.

@fruffy fruffy added wontfix This is a problem that will not be fixed. and removed invalid labels Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This behavior is unintended and should be fixed. wontfix This is a problem that will not be fixed.
Projects
None yet
Development

No branches or pull requests

4 participants