[SOLVED] Segmentation fault with console app lazarus / 1-Linux ---------------------------------------------------------------------- clauslack · 2009-12-12 22:21 I upgrade from kernel 2.4.36 to 2.6.31.6 SMP and all console application now show Segmentation fault Intel(R) Pentium(R) Dual  CPU  E2160  @ 1.80GHz kernel 2.6.31.6 SMP in /var/log/messages show Dec 12 18:35:25 linuxscsi kernel: project1[1343]: segfault at 21 ip 00000021 sp bf9d3144 error 4 in project1[8048000+4d000] project1 has a simple writeln('hola') but with kernel 2.4 works fine Any Idea? SMP and Freepascal not work? Dosemu not work too. but other app work fine (samba, firebird, lighttpd, etc) Thanks ---------------------------------------------------------------------- Marc · 2009-12-14 11:34 Console apps sure run on those machines (remeber the compiler itself is also a console app) What is your console app doing ? what happens if you run it in gdb ? ---------------------------------------------------------------------- clauslack · 2009-12-14 13:08 Under Intel(R) Pentium(R) Dual  CPU  E2160  @ 1.80GHz with kernel 2.4 (without smp) all console app run fine. When I compile the linux kernel 2.6.31.6 with SMP support; all console app. show segmentation fault, even a simple writeln('hello world') FreePascal is not instaled in this machine. In other Linux 2.6 (with SMP) work fine. I will test with gdb and I will recompile the kernel 2.6 without SMP and try again. Thanks ---------------------------------------------------------------------- marcov · 2009-12-14 15:34 Quote from: clauslack on December 14, 2009, 02:08:15 pmUnder Intel(R) Pentium(R) Dual  CPU  E2160  @ 1.80GHz with kernel 2.4 (without smp) all console app run fine. When I compile the linux kernel 2.6.31.6 with SMP support; all console app. show segmentation fault, even a simple writeln('hello world') FreePascal is not instaled in this machine. In other Linux 2.6 (with SMP) work fine. Heaps of people run FPC on multicore machines, so I wouldn't automatically assume it is that. A gdb trace would be best. ---------------------------------------------------------------------- clauslack · 2009-12-20 18:55 Hi With cat /proc/cpuinfo processor       : 0 vendor_id       : GenuineIntel cpu family      : 6 model           : 15 model name      : Intel(R) Pentium(R) Dual  CPU  E2160  @ 1.80GHz processor       : 1 vendor_id       : GenuineIntel cpu family      : 6 model           : 15 model name      : Intel(R) Pentium(R) Dual  CPU  E2160  @ 1.80GHz The SMP works. I use prelocompiled SMP kernel 2.6.27 from Slackware, all app. work (with processor M486). But if I compile the kernel 2.6.31.8 with processor MPentium3, all app. from freepascal show Segmentation fault. Firebird, Samba (works) Look like freepascal app. not work with SMP Pentium3, but work with SMP 486. The app. is a simple writeln('Hola). Here is the backtrace. QuoteGNU gdb (GDB) 7.0 Copyright (C) 2009 Free Software Foundation, Inc. Starting program: /home/claudio/bases/temp/syscami-bin/pro386 Program received signal SIGSEGV, Segmentation fault. 0x00000021 in ?? () (gdb) bt #0  0x00000021 in ?? () #1  0x080484dc in SYSTEM_FPSYSCALL$LONGINT$LONGINT$LONGINT$$LONGINT () #2  0x08048b3e in SYSTEM_FPUGETRLIMIT$LONGINT$PRLIMIT$$LONGINT () #3  0x0805f547 in SYSTEM_CHECKINITIALSTKLEN$LONGWORD$$LONGWORD () #4  0x00000000 in ?? () (gdb) I will test compile kernel 2.6.31.8 with SMP M686 (PentiumPro). Some cthreads problem??? Any idea? Regards ---------------------------------------------------------------------- Marc · 2009-12-20 23:50 A simple app doesn't use threads and runs on one core. You're looking in the wrong direction. FPC has run for years (and still runs) on my dual PIII The dump you gave doesn't look like a simple hello world. Can you paste the source ? ---------------------------------------------------------------------- clauslack · 2009-12-21 01:05 @Marc What kernel version do you have? With kernel 2.6.31.9 SMP M486/MPentium/MPentium3 freepascal app. not work. But with a precompiled kernel 2.6.27.8 SMP M486 freepascal app.work; in the same machine. I have many console app. build with fpc 2.2.4(cgi, database), all show segmentation fault IP:21. Code: [Select]program Project1; {$mode objfpc}{$H+} uses   {$IFDEF UNIX}{$IFDEF UseCThreads}   cthreads,   {$ENDIF}{$ENDIF}   Classes   { you can add units after this }; {$IFDEF WINDOWS}{$R project1.rc}{$ENDIF} begin writeln('Hola'); end. I take the .config (working) from 2.6.27.8 and compiled with 2.6.31.9, and not work. I use gcc 3.2 (I read kernel Documentation/Changes) I will compile other kernel version, for try find the problem. Regards ---------------------------------------------------------------------- Marc · 2009-12-21 10:32 I'm running 2.6.26.8-57.fc8 Still need to upgrade some day ---------------------------------------------------------------------- Bart · 2009-12-21 23:03 What happens if you make an even smaller app. Skip all uses clauses for example. Code: [Select]program foo; {$mode objfpc} begin end. or Code: [Select]program foo; {$mode objfpc} begin   writeln('Hello World'); end. Bart ---------------------------------------------------------------------- clauslack · 2009-12-22 00:08 ok, I will test that. (Maybe with a disassembler) After check with other version of kernel 2.6 SMP. Regards ---------------------------------------------------------------------- clauslack · 2009-12-26 13:49 After many, many, many test (kernel compilations) I found the two problem. 1) FreePascal App. show Segmentation Fault with kernel 2.6 SMP. 2) Dosemu non root show Segmentation Fault with kernel 2.6 SMP. Case 1) The problem was the kernel compiled with gcc 3.2.2, finally upgrade to gcc 3.3.6 and works!! (only  affect to fpc app.) Code: [Select] 0804841D:  83C004             add eax, 0x4 ald> s eax = 0xBFBF7F30 ebx = 0x00000001 ecx = 0x00000001 edx = 0x00000000 esp = 0xBFBF7E8C ebp = 0xBFBF7EA8 esi = 0x00000007 edi = 0x00000000 ds  = 0x007B es  = 0x007B fs  = 0x0000 gs  = 0x0000 ss  = 0x007B cs  = 0x0073 eip = 0x08048420 eflags = 0x00000296 Flags: PF AF SF IF 08048420:  8B10                 mov edx, dword [eax] ald> examine 0xbfbf7f30 Dumping 64 bytes of memory starting at 0xBFBF7F30 in hex BFBF7F30:  20 00 00 00 21 00 00 00 10 00 00 00 FF FB EB BF     ...!........... // Here save 0x21 ald> disas 0x0804841d (maybe procedure InitSyscallIntf; rtl/linux/i386/syscall.inc) 0804841D:  83C004               add eax, 0x4 08048420:  8B10                 mov edx, dword [eax] 08048422:  83FA20               cmp edx, 0x20 08048425:  7519                 jne +0x19 (0x8048440:SYSTEM_INITSYSCALLINTF+0x40) 08048427:  8B5004               mov edx, dword [eax+0x4] //here save bad pointer 0x21 0804842A:  8915B4540908         mov dword [+0x80954b4], edx 08048430:  85D2                 test edx, edx 08048432:  7415                 je +0x15 (0x8048449:SYSTEM_INITSYSCALLINTF+0x49) 08048434:  C705B054090801000000 mov dword [+0x80954b0], 0x1 0804843E:  EB09                 jmp short +0x9 (0x8048449:SYSTEM_INITSYSCALLINTF+0x49) 08048440:  83C008               add eax, 0x8 08048443:  8B10                 mov edx, dword [eax] 08048445:  85D2                 test edx, edx 08048447:  75D7                 jne +0xd7 (0x8048520:SYSTEM_FPSYSCALL$LONGINT$LONGINT$LONGINT$LONGINT $$LONGINT+0x20) 08048449:  C3        // Try to run invalid 0x21 080484D6:  FF15B4540908         call near dword [+0x80954b4] ald> s eax = 0x000000BF ebx = 0x00000003 ecx = 0xBFAEFD6C edx = 0x00000003 esp = 0xBFAEFD54 ebp = 0xBFAEFD60 esi = 0x00040000 edi = 0x00000000 ds  = 0x007B es  = 0x007B fs  = 0x0000 gs  = 0x0000 ss  = 0x007B cs  = 0x0073 eip = 0x00000021 eflags = 0x00000202 Flags: IF Error disassembling next instruction (address: 0x00000021) Dumping 64 bytes of memory starting at 0x080954B4 in hex 080954B4:  21 00 00 00 00 00 8D B6 00 00 00 00 00 00 00 00    !............... // rtl/linux/system.pp {$if defined(i386) and not defined(FPC_USE_LIBC)}   InitSyscallIntf; {$endif} Case 2) The kernel 2.6.31.9 has the option    CONFIG_DEFAULT_MMAP_MIN_ADDR=4096, must be 0 for dosemu. or echo 0 > /proc/sys/vm/mmap_min_addr http://kernel.xc.net/html/linux-2.6.31/x86/DEFAULT_MMAP_MIN_ADDR Now all work 100% , Intel dual core, kernel 2.6.31.9 SMP 32bits compiled for Pentium3. Thanks