From owner-freebsd-threads@FreeBSD.ORG Tue Oct 14 11:59:16 2003 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 922A716A4B3 for ; Tue, 14 Oct 2003 11:59:16 -0700 (PDT) Received: from omnivergent.com (mailex01.readyhosting.com [63.99.209.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id C816143FBF for ; Tue, 14 Oct 2003 11:59:05 -0700 (PDT) (envelope-from Dan@omnivergent.com) Received: from dang [198.123.44.81] by omnivergent.com with ESMTP (SMTPD32-7.07) id A7B841BC0104; Tue, 14 Oct 2003 14:00:08 -0500 From: To: Date: Tue, 14 Oct 2003 11:59:30 -0700 Message-ID: <000701c39285$4d5aae40$c90a0a0a@omni> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Subject: Thread func parameter address problem (BSD 4.8) X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: dgrammas@omnivergent.com List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Oct 2003 18:59:16 -0000 Hello, I have a threading runtime problem, and I was hoping you all could give me a little direction. I am writing a little divert sockets app on FreeBSD 4.8 release. I recompiled the kernel with the following options: options MROUTING # Multicast routing options IPFIREWALL #firewall options IPFIREWALL_VERBOSE #enable logging to syslogd(8) options IPFIREWALL_FORWARD #enable transparent proxy support options IPFIREWALL_VERBOSE_LIMIT=100 #limit verbosity options IPFIREWALL_DEFAULT_TO_ACCEPT #allow everything by default options IPV6FIREWALL #firewall for IPv6 options IPV6FIREWALL_VERBOSE options IPV6FIREWALL_VERBOSE_LIMIT=100 options IPV6FIREWALL_DEFAULT_TO_ACCEPT options IPDIVERT #divert sockets options IPSTEALTH #support for stealth forwarding options TCPDEBUG # Because I have a dual Pentium pro options SMP # Symmetric MultiProcessor Kernel options APIC_IO # Symmetric (APIC) I/O options HTT # HyperThreading Technology Things worked fine until I tried to add a thread to my code. Here is my init code: void initialize_threads(sendqueuehead *sq, dc_info *pinfo) { pthread_t pth; pthread_attr_t pth_atr = NULL; int retval = 0; if (pthread_mutex_init(&pth_mutex, NULL)) { syslog(LOGERR, "cannot create mutext)"); perror("[initialize_threads] cannot create mutext"); exit(EXIT_FAILURE); } if (pthread_mutex_init(&pth_mutex_sendq, NULL)) { syslog(LOGERR, "cannot create mutext)"); perror("[initialize_threads] cannot create mutext"); exit(EXIT_FAILURE); } pthread_attr_init(&pth_atr); pthread_attr_setdetachstate(&pth_atr, PTHREAD_CREATE_DETACHED); retval =pthread_create(&pth, &pth_atr, hacpackets, (char *)pinfo); pthread_create(&pth, &pth_atr, heartbeat_timeout, sq); return; } When the function hacpackets() is started, its parameter address is off by 1 byte. In gdb, pinfo is fine in the initialize_threads functions, but in the hacpackets() function (since the address is off by one) I get a segmentation fault. Do threads work OK on 4.8? Is this an SMP problem? Any ideas? Thanks for the help. Regards Dan P.S. My dmesg at boot... Copyright (c) 1992-2003 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD 4.8-RELEASE #2: Sun Aug 17 17:55:54 PDT 2003 root@itchie.omni.com:/usr/obj/usr/src/sys/SMP Timecounter "i8254" frequency 1193182 Hz CPU: Pentium Pro (198.67-MHz 686-class CPU) Origin = "GenuineIntel" Id = 0x617 Stepping = 7 Features=0xfbff real memory = 134217728 (131072K bytes) avail memory = 125902848 (122952K bytes) Programming 24 pins in IOAPIC #0 FreeBSD/SMP: Multiprocessor motherboard cpu0 (BSP): apic id: 0, version: 0x00040011, at 0xfec08000 cpu1 (AP): apic id: 4, version: 0x00040011, at 0xfec08000 io0 (APIC): apic id: 13, version: 0x00170011, at 0xfec00000 Preloaded elf kernel "kernel" at 0xc049a000. Pentium Pro MTRR support enabled md0: Malloc disk npx0: on motherboard npx0: INT 16 interface pcib0: on motherboard pci0: on pcib0 isab0: at device 18.0 on pci0 isa0: on isab0 atapci0: port 0xffa0-0xffaf at device 18.1 on pci0 ata0: at 0x1f0 irq 14 on atapci0 ata1: at 0x170 irq 15 on atapci0 pcib1: at device 20.0 on pci0 pci1: on pcib1 ahc0: port 0xec00-0xecff mem 0xfaeff000-0xfaefffff irq 11 at device 5.0 on pci1 ahc0: Using left over BIOS settings aic7880: Ultra Wide Channel A, SCSI Id=7, 16/253 SCBs fxp0: port 0xe800-0xe81f mem 0xfad00000-0xfadfffff,0xf78ff000-0xf78fffff irq 11 at device 10.0 on pci1 fxp0: Ethernet address 00:a0:c9:06:69:f7 nsphy0: on miibus0 nsphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto pci1: at 15.0 orm0: