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

Cannot use cnip to complete the missing code, and cnip test.c produces no output. #155

Open
guye opened this issue Nov 1, 2024 · 4 comments
Labels

Comments

@guye
Copy link

guye commented Nov 1, 2024

Description
Using cnip test.c produces no output. The content of test.c is as follows:
int main()
{
T a = 0;
T->value = 3.14;
T->next = a;
return 0;
}

Version
(e0e6e05)

Expected behavior
Output the completed code.

@guye guye added the bug label Nov 1, 2024
@pronesto
Copy link

pronesto commented Nov 1, 2024

Hi!

Using psyche-c's online interface I get:

#define NULL ((void*)0)
typedef unsigned long size_t;  // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__;  // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */
typedef  struct TYPE_2__   TYPE_1__ ;

/* Type definitions */
struct TYPE_2__ {double value; int /*<<< orphan*/  next; } ;
typedef  int /*<<< orphan*/  T ;

/* Variables and functions */
 TYPE_1__* T ; 


//-------------------------
int main()
{
T a = 0;
T->value = 3.14;
T->next = a;
return 0;
}

Is cnip working at all in your environment? Do you see any error message?

@ltcmelo
Copy link
Owner

ltcmelo commented Nov 2, 2024

@guye for type inference you should use the reconstruct.py script from the original branch (as in this screenshot from the README).

@guye
Copy link
Author

guye commented Nov 7, 2024

Sorry, it was my mistake. Previously, I was compiling in the Cygwin environment on Windows, and I could compile cnip on the master branch, but I couldn't use reconstruct.py. After switching to the original branch, the compilation failed in the Cygwin environment. Therefore, I switched to the Ubuntu 22.04 environment, and encountered some minor issues during compilation, as follows:

/usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:280:33: note: ‘std::size_t’ declared here
  280 |   typedef __SIZE_TYPE__         size_t;
      |                                 ^~~~~~
/home/zenkoo/opensource/psychec/frontend/Symbols.cpp:594:24: error: ‘i’ was not declared in this scope
  594 |     for (size_t i = 0; i < original->_baseClasses.size(); ++i)
      |                        ^
At global scope:

After simply handling the errors, the compilation was successful, but when calling ./reconstruct.py test.c, another issue occurred, as shown below:

Traceback (most recent call last):
  File "./reconstruct.py", line 70, in <module>
    analyser.analyse()
  File "./reconstruct.py", line 60, in analyse
    self.solve_constraints()
  File "./reconstruct.py", line 41, in solve_constraints
    "-o", "../%s" % self.gen_file_name])
  File "/usr/lib/python2.7/subprocess.py", line 172, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

ENV:
Python 2.7.18
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
original branch commit 4322192336d

@ltcmelo
Copy link
Owner

ltcmelo commented Nov 9, 2024

I suspect that either the generator or solver might have not been build. You could check whether files psychecgen and psychecsolver-exe are present in your directory; if they aren't, then there's still an issue in your environment. For the solver, you'd need to setup Haskell in your system (keep in mind that Psyche's environment is older than that for Ubuntu 22.04).

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

No branches or pull requests

3 participants