Programatorske: vicevlaknova aplikace negeneruje core

Karel Zak zakkr na zf.jcu.cz
Úterý Listopad 20 10:52:33 CET 2001


On Mon, Nov 19, 2001 at 08:09:42PM +0100, Vladimir Michl wrote:
> 
> Dobry den,
> 
> nesetkali jste se s tim, ze Vam vicevlakova aplikace odmitala generovat
> core soubor pri SIGSEGV?

 <snakeoil>
    Myslite, ze vam core odhali misto kde je chyba? 
 </snakeoil>


 Cetl jste FAQ?

G.2: Does it work with post-mortem debugging?

Not very well. Generally, the core file does not correspond to
the thread that crashed. The reason is that the kernel will
not dump core for a process that shares its memory with other
processes, such as the other threads of your program. So, the
thread that crashes silently disappears without generating a
core file. Then, all other threads of your program die on the
same signal that killed the crashing thread. (This is required
behavior according to the POSIX standard.) The last one that
dies is no longer sharing its memory with anyone else, so the
kernel generates a core file for that thread. Unfortunately,
that's not the thread you are interested in.


 G.3: Any other ways to debug multithreaded programs, then?

Assertions and printf() are your best friends. ....
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

... doporucuji tuto vetu vytetovat na hrud kazdeho programatora, 
ktery jiz docetl "Ucebnice jazyka C, dil 1." a vrha se to viru 
vyvoje aplikaci :-)


> Pouziva to POSIX threads a bezi na jadre 2.2.19 s glibc 2.1.3. Aplikace mi
> obcas sleti a nevim proc. Tak jsem nastavil ulimit -c na unlimited a
> presto aplikace odmita vytvorit core. Jo jednou jedinkrat mi nejaky core
> vygenerovala a to bylo vse. Vsechny ostatni pokudy konci bez core.
> 
> Jedno vlakno se v aplikaci pouziva na spousteni externich prikazu pomoci
> popen, ktere pak generuje signal SIGCHLD,ve kterem jenom odchytnu
> navratovy kod. To je tak asi vse zajimave.

 pthread a signaly jsou vec pekelna. Je treba myslet na tyto zakladni
 veci:
    - signal handlers are shared between all threads (je tedy otazkou
      kdo ve vasi aplikaci dostane toho CHILDa a kdo ho zpracovava)
    - ale thread si muze nastavil vlastni masku k signalum (IMHO by to
      mel udelat).

 
        Karel
 
-- 
 Karel Zak  <zakkr na zf.jcu.cz>
 http://home.zf.jcu.cz/~zakkr/
 
 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz


Další informace o konferenci Linux