schnorr / mlp

Disciplina de Modelos de Linguagens de Programação - INF/UFRGS
19 stars 11 forks source link

CATP #17 #30

Closed btrevizan closed 5 years ago

btrevizan commented 5 years ago

Estou com dificuldade em identificar e corrigir os erros do imsobuggy. O valgrind está apresentando erros como:

==54554== Use of uninitialised value of size 8
==54554==    at 0x10060D24E: objc_initializeClassPair_internal(objc_class*, char const*, objc_class*, objc_class*) (in /usr/lib/libobjc.A.dylib)
==54554==    by 0x1005AE6C5: _libxpc_initializer (in /usr/lib/system/libxpc.dylib)
==54554==    by 0x1000FE9C9: libSystem_initializer (in /usr/lib/libSystem.B.dylib)
==54554==    by 0x10001BCC7: ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==54554==    by 0x10001BEC5: ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==54554==    by 0x1000170D9: ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) (in /usr/lib/dyld)
==54554==    by 0x10001706C: ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) (in /usr/lib/dyld)
==54554==    by 0x100016253: ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) (in /usr/lib/dyld)
==54554==    by 0x1000162E7: ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) (in /usr/lib/dyld)
==54554==    by 0x10000572D: dyld::initializeMainExecutable() (in /usr/lib/dyld)
==54554==    by 0x10000A78E: dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) (in /usr/lib/dyld)
==54554==    by 0x1000044F5: dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) (in /usr/lib/dyld)

Parecem ser erros de alguma biblioteca. Porém, como faço para corrigir esses erros? Tentei verificar se não é o próprio programa que causa esses erros, mas não cheguei a nenhuma conclusão.

schnorr commented 5 years ago

Parece ser de fato um problema oriundo da inicilização do programa. Em qual sistema isso é obtido?

Em um Linux recente, a lista obtida com o comando valgrind --leak-check=full ./imsobuggy é a seguinte:

==29557== Memcheck, a memory error detector
==29557== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==29557== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==29557== Command: ./imsobuggy
==29557== 
==29557== Conditional jump or move depends on uninitialised value(s)
==29557==    at 0x1092DC: VectorSet (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x1091CD: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== Conditional jump or move depends on uninitialised value(s)
==29557==    at 0x10948B: ResizeArray (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x109307: VectorSet (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x1091CD: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== Conditional jump or move depends on uninitialised value(s)
==29557==    at 0x1094BA: ResizeArray (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x109307: VectorSet (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x1091CD: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== Use of uninitialised value of size 8
==29557==    at 0x1094A8: ResizeArray (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x109307: VectorSet (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x1091CD: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== Conditional jump or move depends on uninitialised value(s)
==29557==    at 0x48BE8CA: vfprintf (vfprintf.c:1642)
==29557==    by 0x48C5F75: printf (printf.c:33)
==29557==    by 0x109531: PrintIntVector (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x1091E3: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== Use of uninitialised value of size 8
==29557==    at 0x48BA7BB: _itoa_word (_itoa.c:179)
==29557==    by 0x48BDFAF: vfprintf (vfprintf.c:1642)
==29557==    by 0x48C5F75: printf (printf.c:33)
==29557==    by 0x109531: PrintIntVector (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x1091E3: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== Conditional jump or move depends on uninitialised value(s)
==29557==    at 0x48BA7C5: _itoa_word (_itoa.c:179)
==29557==    by 0x48BDFAF: vfprintf (vfprintf.c:1642)
==29557==    by 0x48C5F75: printf (printf.c:33)
==29557==    by 0x109531: PrintIntVector (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x1091E3: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== Conditional jump or move depends on uninitialised value(s)
==29557==    at 0x48BE053: vfprintf (vfprintf.c:1642)
==29557==    by 0x48C5F75: printf (printf.c:33)
==29557==    by 0x109531: PrintIntVector (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x1091E3: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== Conditional jump or move depends on uninitialised value(s)
==29557==    at 0x48BE134: vfprintf (vfprintf.c:1642)
==29557==    by 0x48C5F75: printf (printf.c:33)
==29557==    by 0x109531: PrintIntVector (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x1091E3: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== Conditional jump or move depends on uninitialised value(s)
==29557==    at 0x48BE8CA: vfprintf (vfprintf.c:1642)
==29557==    by 0x48C5F75: printf (printf.c:33)
==29557==    by 0x109560: PrintIntVector (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x1091E3: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== Use of uninitialised value of size 8
==29557==    at 0x48BA7BB: _itoa_word (_itoa.c:179)
==29557==    by 0x48BDFAF: vfprintf (vfprintf.c:1642)
==29557==    by 0x48C5F75: printf (printf.c:33)
==29557==    by 0x109560: PrintIntVector (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x1091E3: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== Conditional jump or move depends on uninitialised value(s)
==29557==    at 0x48BA7C5: _itoa_word (_itoa.c:179)
==29557==    by 0x48BDFAF: vfprintf (vfprintf.c:1642)
==29557==    by 0x48C5F75: printf (printf.c:33)
==29557==    by 0x109560: PrintIntVector (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x1091E3: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== Conditional jump or move depends on uninitialised value(s)
==29557==    at 0x48BE053: vfprintf (vfprintf.c:1642)
==29557==    by 0x48C5F75: printf (printf.c:33)
==29557==    by 0x109560: PrintIntVector (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x1091E3: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== Conditional jump or move depends on uninitialised value(s)
==29557==    at 0x48BE134: vfprintf (vfprintf.c:1642)
==29557==    by 0x48C5F75: printf (printf.c:33)
==29557==    by 0x109560: PrintIntVector (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x1091E3: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
[0,0,0,0,0,0,0,0,0,0]
==29557== 
==29557== HEAP SUMMARY:
==29557==     in use at exit: 528 bytes in 22 blocks
==29557==   total heap usage: 23 allocs, 1 frees, 1,552 bytes allocated
==29557== 
==29557== 32 bytes in 1 blocks are definitely lost in loss record 1 of 5
==29557==    at 0x48357BF: malloc (vg_replace_malloc.c:299)
==29557==    by 0x109214: VectorCreate (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x10918D: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== 136 (16 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 5
==29557==    at 0x48357BF: malloc (vg_replace_malloc.c:299)
==29557==    by 0x109200: VectorCreate (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x10918D: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== 360 bytes in 9 blocks are definitely lost in loss record 5 of 5
==29557==    at 0x48357BF: malloc (vg_replace_malloc.c:299)
==29557==    by 0x10943A: ResizeArray (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x109307: VectorSet (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557==    by 0x1091CD: main (in /home/schnorr/ensino/github/mlp/catps/def/17/imsobuggy)
==29557== 
==29557== LEAK SUMMARY:
==29557==    definitely lost: 408 bytes in 11 blocks
==29557==    indirectly lost: 120 bytes in 11 blocks
==29557==      possibly lost: 0 bytes in 0 blocks
==29557==    still reachable: 0 bytes in 0 blocks
==29557==         suppressed: 0 bytes in 0 blocks
==29557== 
==29557== For counts of detected and suppressed errors, rerun with: -v
==29557== Use --track-origins=yes to see where uninitialised values come from
==29557== ERROR SUMMARY: 58 errors from 17 contexts (suppressed: 0 from 0)
btrevizan commented 5 years ago

Parece ser de fato um problema oriundo da inicilização do programa. Em qual sistema isso é obtido?

Mac OS. São esses erros que aparecem. Por que isso acontece?

schnorr commented 5 years ago

Olá @btrevizan, tudo indica que trata-se de um bug na função de inicialização de programas no Mac OS, especificamente na função objc_initializeClassPair_internal que acaba sendo chamada quando dyldbootstrap::start acontece.