Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C/C++ - Shutting down Allegro due to signal #11
Forum - C/C++ - Shutting down Allegro due to signal #11

Avatar
sarbaturino (Normal User)
Pro


Messaggi: 66
Iscritto: 25/04/2011

Segnala al moderatore
Postato alle 17:51
Giovedì, 05/01/2012
Salve programmatori..
Sto iniziando a programmare con la libreria grafica allegro.h
Ma durante la compilazione di un mio programmino di prova, il compilatore mi da questo errore:

Shutting down Allegro due to signal #11
   Errore di segmentazione

Che non riesco a capire la sua causa..
Qualcuno di vai mi saprebbe aiutare per tale problema??

Vi ringrazio in anticipo per una vostra gentile risposta..:k:

PM
Avatar
Pitagora (Member)
Expert


Messaggi: 367
Iscritto: 12/06/2010

Up
0
Down
V
Segnala al moderatore
Postato alle 18:12
Giovedì, 05/01/2012
Penso che sia quello che serve a te:
Codice sorgente - presumibilmente Delphi

  1. crashes under Linux/Unix
  2.  
  3. When your Allegro compiled Linux/Unix program crashes, you will usually get a not very meaningful message along with a core dump:
  4.  
  5.       Shutting down Allegro due to signal #11
  6.       Segment violation (core dumped)
  7. Look at your filesystem: there should be a file named core or something similar with information telling you exactly where the crash occurred. If there is no core, check your environment settings, under bash this is done with the 'ulimit -a' command. Usually 'ulimit -c unlimited' somewhere in your login scripts should work fine.
  8. Just like with djgpp, to make sense of the core, you should compile your program with debugging information (using the -g switch), and then run the GNU debugger on it "gdb binary core". That will load the debugger, print some information about linked libraries and leave you at a prompt. Now you can get the full backtrace:
  9.  
  10.       (gdb) backtrace
  11.       #0  0x08065237 in utf8_getx (s=0xbffffc5c) at ./src/unicode.c:347
  12.       #1  0x0806953f in ustrzcpy (dest=0x0, size=2147483646, src=0x0) at ./src/unicode.c:1770
  13.       #2  0x08057575 in _mangled_main () at t.c:9
  14.       #3  0x0806c9bf in main (argc=1, argv=0xbffffd14) at ./src/unix/umain.c:39
  15.       #4  0x4015414f in __libc_start_main () from /lib/libc.so.6
  16. In this case, you can see that the crash occurred in the ustrzcpy() function, which was called at line 9 of the main() function in the t.c source file. Now you just have to go to that line, have a look at whatever you are doing there, and change it to be correct :-)
  17. Note that the crash happened deep inside an Allegro function, which is also revealed by the traceback. However, the binary was linked against a static debug version of Allegro, we wouldn't have had so much luck with a non debug or dynamically linked version.
  18.  
  19. Since gdb is an interactive debugger, you could also select a frame and check out the values of the variables, to see better who is the culprit:
  20.  
  21.      (gdb) frame 2
  22.      #2  0x08057575 in _mangled_main () at t.c:9
  23.      9          ustrcpy(p1, p2);
  24.      (gdb) list
  25.      4
  26.      5       int main(void)
  27.      6       {
  28.      7          char *p1 = 0, *p2 = 0;
  29.      8          allegro_init();
  30.      9          ustrcpy(p1, p2);
  31.      10         return 0;
  32.      11      }
  33.      12      END_OF_MAIN()
  34.      (gdb) print p1
  35.      $1 = 0x0
  36.      (gdb) print p2
  37.      $2 = 0x0
  38. Yuck! Playing with NULL values doesn't really pay off. Ok, while this was a slightly out-of-the-can example, you surely get the point. Remember to check out GDB's manual to learn about more useful commands and/or how to debug your program while it's running and many other things. You might also want to check out Peter Wang's "Debugging with GDB" article, featured in the ninth number of the Pixelate online magazine (http://pixwiki.bafsoft.com/).



... Se poi rendi pubblico il codice :heehee:

Ultima modifica effettuata da Pitagora il 05/01/2012 alle 18:13
Ciao e grazie per aver risposto al mio problema..Ho visto ciò che mi hai scritto ma non riesco a capire cosa dovrei fare!!Mi potresti spiegare meglio? - sarbaturino - 06/01/12 16:59
niente di che. Devi debbugarlo e capire dove in che istruzione crasha. - Pitagora - 06/01/12 22:21
PM
Avatar
Nullable (Normal User)
Expert


Messaggi: 217
Iscritto: 12/07/2011

Up
0
Down
V
Segnala al moderatore
Postato alle 19:44
Giovedì, 05/01/2012
Io non so aiutarti in questo, scrivo questo post per correggerti : allegro.h è un file di intestazione ( header ) non una libreria ( le librerie sono o statiche [.lib] o dinamiche [.dll] ).

PM