1 |
Dan Johansson <Dan.Johansson@×××.nu> [16-06-26 18:12]: |
2 |
> The following code snippet compiles find but when run it just hangs forever: |
3 |
> |
4 |
> $ cat x.c |
5 |
> #include <stdio.h> |
6 |
> #include <unistd.h> |
7 |
> #include <crypt.h> |
8 |
> |
9 |
> int main() { |
10 |
> printf("Running test\n"); |
11 |
> char *encrypted = crypt("blablabla","ab"); |
12 |
> if(!encrypted || strcmp(encrypted,"ab.h7fshjf89f")) { |
13 |
> printf("Fail\n"); |
14 |
> } else { |
15 |
> printf("OK\n"); |
16 |
> } |
17 |
> } |
18 |
> |
19 |
> $ gcc -o xout x.c -lcrypt |
20 |
> |
21 |
> $ ./xout |
22 |
> Running test |
23 |
> |
24 |
> <here the program just hangs and needs to be killed with ^C> |
25 |
> |
26 |
> The same code runs fine on my desktop. |
27 |
> Any suggestions what could be my problem? |
28 |
> |
29 |
> -- |
30 |
> Dan Johansson, <http://www.dmj.nu> |
31 |
> *************************************************** |
32 |
> This message is printed on 100% recycled electrons! |
33 |
> *************************************************** |
34 |
> |
35 |
|
36 |
Hi Dan, |
37 |
|
38 |
this is just a shot in the dark and most likely I will miss the |
39 |
target...but... |
40 |
|
41 |
Off what kind of memory you are running this code? |
42 |
Das "cryot()" returns a pointer to newly acquired memory? |
43 |
May be this memory is not RAM but flash/EEPROM? |
44 |
If crypt() expects already allocated memory at the |
45 |
pointers adress this may work on a PC because its |
46 |
short and the stack is relatively large and you hit |
47 |
nothing ... so it runs accidentally (so to say) and |
48 |
fails on a Raspi... |
49 |
|
50 |
Only some random thoughts... |
51 |
|
52 |
Good luck! |
53 |
Best regards, |
54 |
Meino |