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

Usage of library, runtime error #1

Open
Johanvdberg opened this issue May 2, 2019 · 9 comments
Open

Usage of library, runtime error #1

Johanvdberg opened this issue May 2, 2019 · 9 comments

Comments

@Johanvdberg
Copy link

I want to use the library and started with an example program. When I run the program I get errors (core dump) that move as I add std::cerr statement to follow the execution of the program:

#0  0x00000003f2fb9912 in cygstdc++-6!_ZNSo6sentryC1ERSo ()
from /usr/bin/cygstdc++-6.dll
#1  0x00000003f300bd2a in cygstdc++-6!_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l () from /usr/bin/cygstdc++-6.dll
#2  0x0000000100461fbc in Peigen::function_t<6>::show_all_properties() const    ()
#3  0x00000001004037fe in Peigen::weight::lighter<6>::evaluate_verbose(std::string, std::string) [clone ._omp_fn.0] ()
#4  0x00000003f7c25562 in cyggomp-1!GOMP_parallel ()  from /usr/bin/cyggomp-1.dll
#5  0x0000000100424e97 in Peigen::weight::lighter<6>::evaluate_verbose(std::string, std::string) ()
#6  0x0000000100401786 in evalaute(std::string, std::string, unsigned long) ()
#7  0x0000000100401474 in main () 

I am using cygwin.

The files used are attached.

s_box_evaluation.cpp.txt
s_box_evaluation_wrapper.cpp.txt
s_box_evaluation_wrapper.h.txt

@FreeDisciplina
Copy link
Member

FreeDisciplina commented May 2, 2019

May I knew whether your CPU enable SSSE3 instructions (e.g., pshufb) and POPCNT?
Sorry for that, currently, PEIGEN does not detect whether the CPUs support such instructions. It directly assumes the CPUs enable such instructions.

Besides, may I knew, will the same error occurs when using the example file "sboxes6.txt"?
sboxes6.txt

Another possible point, is that, maybe that error was not caused by PEIGEN. From the std::cerr statement, it seems the error comes from _ZNSo6sentryC1ERSo (). I googled "_ZNSo6sentryC1ERSo ()", and found this page: https://groups.google.com/forum/#!topic/comp.unix.tru64/WHHqM2ZyloM.
It suggested that the compiler is broken... May test the simple sample code to exclude this possibility:
#include <iostream>
int main()
{
std::cout << "Cout dumps core";
}

@Johanvdberg
Copy link
Author

Johanvdberg commented May 2, 2019

The CPU is Intel i7-4790, and use parameter -mavx2 so the the code compile. Will compiler then make sure the CPU support the needed instruction?

I use sboxes6.txt as the input. When I remove the last character of each LUT the error move to a different place and and the program does not complain about the length not being 128 characters long.

The small test program does work.

On which platform was the library developed?

@FreeDisciplina
Copy link
Member

FreeDisciplina commented May 2, 2019

I have tested on the following CPUs and g++:
1.Intel(R) Core(TM) i7-6700, gcc version 5.4.1 20160904 (Ubuntu 5.4.1-2ubuntu1~14.04)
2. Intel(R) Xeon(R) CPU E5-2690 v3, gcc version 5.1.0 (GCC)
3. Intel(R) Core(TM) i5-6500 CPU, gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11)

@FreeDisciplina
Copy link
Member

FreeDisciplina commented May 2, 2019

It seems the program haven't call parse_function() in func.cpp, because, otherwise the program will complain about the length...

I use sboxes6.txt as the input. When I remove the last character of each LUT the error move to a different place and and the program does not complain about the length not being 128 characters long.

Your wrapper file "s_box_evaluation_wrapper.cpp.txt" writes "sbox6_Eva.evaluate_verbose(filename.c_str(), "properties");"
While evaluate_verbose accepts string as the filename,
see:void evaluate_verbose(string sboxesfile, string outputfile_prefix);

Could you change sbox6_Eva.evaluate_verbose(filename.c_str(), "properties"); be
sbox6_Eva.evaluate_verbose(filename, "properties"); and try again.


Sorry for that I can hardly find the problem, I can only try my best to guess.

I have tried to change sbox6_Eva.evaluate_verbose(filename, "properties"); with
sbox6_Eva.evaluate_verbose(filename.c_str(), "properties");
There seems no difference. I can still run the compiled program on Intel(R) Core(TM) i7-6700, gcc version 5.4.1 Ubuntu14.04. Maybe the problem not lies here...

@Johanvdberg
Copy link
Author

I did delete the .c_str() but still get the same behavior.

The function parse_function is called. when the program is run with sboxes6_orig.txt an error is given about the length and when sboxes6_len_ok.txt is used there is not error. The files as in the repository is sboxes6_orig.txt, also the program terminate without a core dump, but the output .txt file does not contain anything besides Fides_6 Sbox:.

sboxes6_len_ok.txt
sboxes6_orig.txt

What is the easiest way to disable openmp?

I am using gcc 7.4.0. Next I will test the program on Cent Os, hopefully that will work.

@FreeDisciplina
Copy link
Member

Note that, the files used as input to the functions of PEIGEN should be encoded in UTF-8 and End of Line (EOL) in Unix (LF) when running on a Linux...

I used to encounter core dump because the input file is of the End of Line (EOL) in windows (CR LF)..
To change the EOL of the file, I used notepad++, Edit->EOL Conversion->Unix(LF)...

I am not sure whether this is because, your input files are with EOL in windows (CR LF)..

The function parse_function is called. when the program is run with sboxes6_orig.txt an error is given about the length and when sboxes6_len_ok.txt is used there is not error. The files as in the repository is sboxes6_orig.txt, also the program terminate without a core dump, but the output .txt file does not contain anything besides Fides_6 Sbox:.

@Johanvdberg
Copy link
Author

Using the correct EOL solved the problem with the length of the sboxes. I still get a core dump using cygwin.

@FreeDisciplina
Copy link
Member

Hi, I tested PEIGEN in cygwin (with g++ version 7.4.0), it worked on my PC.
I also tested your wrapper codes, it also worked.

If you want to test it, you may put the following codes into PEIGEN, and use:
make issue and run issue
make sure that the file contains Sboxes with EOL be Unix(LF).
On my PC, it generated "properties_APN_6.txt", "properties_Fides_6.txt", "properties_SC2000_6.txt" correctly.

issue.zip

@FreeDisciplina
Copy link
Member

FreeDisciplina commented May 15, 2019

So, I guess the issue may caused by the SSE instructions, maybe your PC does not support the POPCNT?
You may use the attached code to test whether your PC support "SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, SSE4a, SSE5, and AVX" and also POPCNT (modified from https://gist.github.com/hi2p-perim/7855506 to support checking POPCNT).

The ssecheck.exe is compiled in cygwin using g++.

ssecheck.zip

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