Author Topic: libc panic  (Read 10073 times)

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 306
  • Karma: +27/-0
    • View Profile
libc panic
« on: July 31, 2015, 07:34:33 am »
Hi.

I'm porting nginx. I was able to build a binary and nginx can serve me static HTML pages.
I can stop nginx via process signaling. That just works fine.
But if I want to restart nginx, I get the following:
Code: [Select]
nginx: [alert] shmget(384) failed (22: Invalid argument)

LIBC PANIC!!
safesem mutex requested failed, rc=0x6. pmtx=5fe10960:{.hmtx=0x800100fb .fShared
=0x1}
pid=0x0fbb ppid=0x0b43 tid=0x0001 slot=0x009c pri=0x0200 mc=0x0001 ps=0x0017
U:\WORK\NGINX\OBJS\NGINX.EXE
Process dumping was disabled, use DUMPPROC / PROCDUMP to enable it.

Now, I have to reboot to get nginx running again.

I have the newest klibc installed and the binary is compiled with gcc 4.9.2.
Does anyone have suggestions, how to handle the problem?

Bye Jochen

PS: If someone wants to test the port, PM me.  I'll send you the binary.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: libc panic
« Reply #1 on: July 31, 2015, 08:07:16 am »
Try adding -Zhigh-mem to your LDFLAGS

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 306
  • Karma: +27/-0
    • View Profile
Re: libc panic
« Reply #2 on: July 31, 2015, 08:11:25 am »
I have already compiled nginx with -Zhigh-mem.
Actually, I used:
Code: [Select]
CFLAGS = -D__EMX__ -DEMX -DOS2 -Zmt  -D__ST_MT_ERRNO__ -g -march=pentium -mtune=pentium4 -static-libgccand
Code: [Select]
LDFLAGS = -Zomf -Zmap -Zhigh-mem -Zstack 8000 -D__ST_MT_ERRNO__ -static-libgcc -lmmap -Zexe
« Last Edit: July 31, 2015, 08:15:13 am by Jochen Schäfer »

Joop

  • Hero Member
  • *****
  • Posts: 633
  • Karma: +5/-0
    • View Profile
Re: libc panic
« Reply #3 on: July 31, 2015, 07:20:39 pm »
All libc panics I had with Java had to do with a short of available memory. I don't know if this is the same in your situation.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 306
  • Karma: +27/-0
    • View Profile
Re: libc panic
« Reply #4 on: August 03, 2015, 01:41:40 pm »
I don't think, it's an memory problem. The problem is consistently the start of nginx after a previous shutdown.

The nginx code for the use of shared memory relies on the automatic removal of shared memory at process shutdown.
My guess is, that klibc ignores this flag and by the time nginx is started the second time, the shared semaphore is still in use and can't be recreated.
That leads to the lib panic.
Does someone know whether I can fetch a list of shared memory segments to release?

dbanet

  • Guest
Re: libc panic
« Reply #5 on: August 03, 2015, 03:26:58 pm »
I know WatchCat can show semaphores per process.

Can also maybe Theseus 4 be useful?

ftp://ftp.boulder.ibm.com/ps/products/os2/fixes/v4.5warp/theseus4/thes4001.exe

By the way, I sent you a PM some time ago...
PS: If someone wants to test the port, PM me.  I'll send you the binary.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 306
  • Karma: +27/-0
    • View Profile
Re: libc panic
« Reply #6 on: August 03, 2015, 03:35:53 pm »
Hi Boris.

Thanks for the hints. Imwill look into the tools.
I didn't forget your PM, I just didn't get to packaging and uploading the binary. Sorry.
Hope to get to it this evening.

Andy Willis

  • Sr. Member
  • ****
  • Posts: 292
  • Karma: +7/-0
    • View Profile
Re: libc panic
« Reply #7 on: August 03, 2015, 05:15:53 pm »
What does -D__ST_MT_ERRNO__ do?  I have recently come across it and couldn't determine what its purpose was.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: libc panic
« Reply #8 on: August 03, 2015, 05:27:19 pm »
What does -D__ST_MT_ERRNO__ do?  I have recently come across it and couldn't determine what its purpose was.

On EMX, it was needed when using the multithreading version of the library along with -Zmt. Now it is just a no-op as kLIBC only supports multi-threading. (Programs aimed at DOS had to be single threaded)