Skip to content

Comments

wechat: init at 4.0.0.30 (linux) / 4.0.0.5 (darwin) #354332

Closed
pluiedev wants to merge 1 commit intoNixOS:masterfrom
pluiedev:push-zsqvytnxxrtr
Closed

wechat: init at 4.0.0.30 (linux) / 4.0.0.5 (darwin) #354332
pluiedev wants to merge 1 commit intoNixOS:masterfrom
pluiedev:push-zsqvytnxxrtr

Conversation

@pluiedev
Copy link
Member

@pluiedev pluiedev commented Nov 7, 2024

Fixes #354234

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@pluiedev pluiedev changed the title wechat: init at 0.0.0 wechat: init Nov 7, 2024
@pluiedev
Copy link
Member Author

pluiedev commented Nov 7, 2024

Details about the segfault:

$ lldb ./result/bin/wechat
(lldb) target create "./result/bin/wechat"
Current executable set to '/home/leah/coding/nixpkgs/result/bin/wechat' (x86_64).
(lldb) run
Process 103844 launched: '/home/leah/coding/nixpkgs/result/bin/wechat' (x86_64)
Process 103844 stopped
* thread #43, name = 'mmui::utility::', stop reason = signal SIGSEGV: address not mapped to object (fault address: 0x10)
    frame #0: 0x000055555e510008 wechat`___lldb_unnamed_symbol227806 + 232
wechat`___lldb_unnamed_symbol227806:
->  0x55555e510008 <+232>: movq   0x10(%rax), %rdx
    0x55555e51000c <+236>: addq   %rax, %rdx
    0x55555e51000f <+239>: movl   0x4(%rax), %eax
    0x55555e510012 <+242>: orq    %rax, %rbx

@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Nov 8, 2024
@UlyssesZh
Copy link
Member

Currently segfaults and I have no idea why :(

Is it the same problem as #327860? Try the fix in #335658.

@UlyssesZh
Copy link
Member

By the way, we may also support loongarch64-linux since you are using the deb as the source.

@pluiedev
Copy link
Member Author

pluiedev commented Nov 8, 2024

By the way, we may also support loongarch64-linux since you are using the deb as the source.

Does Nixpkgs even have loongarch support, like, at all...?

@UlyssesZh
Copy link
Member

Appears so.

@pluiedev
Copy link
Member Author

pluiedev commented Nov 8, 2024

Currently segfaults and I have no idea why :(

Is it the same problem as #327860? Try the fix in #335658.

I tried adding the fix but it doesn't seem to work — looking at the stacktrace the SIGSEGV appears to be caused by something else

@UlyssesZh
Copy link
Member

Someone wrote this.

作者:astrojhgu
链接:https://www.zhihu.com/question/3360014967/answer/26535041734
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

{ makeWrapper, xorg, gcc, fontconfig, libxml2, stdenv, lib, dpkg
, autoPatchelfHook, qt5, libGL, libsForQt5, zlib, nss, nspr, bzip2, libxkbcommon
, glib, dbus, atk, mesa, libdrm, expat, pango, cairo, alsa-lib }:
let
  libPath = lib.makeLibraryPath ([
    pango.out
    xorg.libxcb
    xorg.libXcomposite
    xorg.libXrender
    xorg.libXrandr
    xorg.xcbutilwm.out
    xorg.xcbutilimage.out
    xorg.xcbutilrenderutil.out
    xorg.xcbutilkeysyms.out
    xorg.libX11.out
    xorg.libXdamage.out
    xorg.libXext.out
    xorg.libXfixes.out
    mesa.out
    libGL.out
    alsa-lib.out
    libdrm.out
    cairo.out
    expat.out
    fontconfig.lib
    dbus.lib
    nss.out
    nspr.out
    bzip2.out
    zlib.out
    libxkbcommon.out
    glib
    atk.out
    (lib.getLib gcc.cc)
  ]);

in stdenv.mkDerivation {
  name = "wechat";
  pname = "wechat";
  version = "4.0";
  outputs = [ "out" ];

  src = /etc/nixos/pkgs/wechat/WeChatLinux_x86_64.deb;

  phases = [ "unpackPhase" "installPhase" "fixupPhase" ];

  buildInputs = [
    dpkg
    xorg.libX11.out
    xorg.libXScrnSaver
    xorg.libXft.out
    (lib.getLib gcc.cc)
    fontconfig.lib
    libxml2.out
  ];

  nativeBuildInputs = [ autoPatchelfHook makeWrapper ];

  unpackPhage = ''
    dpkg -x $src ./wechat
  '';

  installPhase = ''
    runHook preInstall
    mkdir -p $out $out/bin
    cp -r ./* $out/
    runHook postInstall
  '';

  fixupPhase = ''
        	
            #patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
            patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
              --set-rpath $out/opt/wechat:${libPath} $out/opt/wechat/wechat

    	  makeWrapper $out/opt/wechat/wechat $out/bin/wechat --prefix LD_LIBRARY_PATH : $out/opt/wechat:${libPath}
              
  '';
}

@pluiedev
Copy link
Member Author

pluiedev commented Nov 10, 2024

Still segfaults but fortunately at a different location now. Progress?
(EDIT: Never mind - it appears that the original segfault still occurs)

(lldb) target create "./result/bin/wechat"
Current executable set to '/home/leah/coding/nixpkgs/result/bin/wechat' (x86_64).
(lldb) run
Process 1091167 launched: '/home/leah/coding/nixpkgs/result/bin/wechat' (x86_64)
Process 1091167 stopped
* thread #1, name = 'wechat', stop reason = exec
    frame #0: 0x00007ffff7fe2840 ld-linux-x86-64.so.2`_start
ld-linux-x86-64.so.2`_start:
->  0x7ffff7fe2840 <+0>: movq   %rsp, %rdi
    0x7ffff7fe2843 <+3>: callq  0x7ffff7fe3520 ; _dl_start

ld-linux-x86-64.so.2`_dl_start_user:
    0x7ffff7fe2848 <+0>: movq   %rax, %r12
    0x7ffff7fe284b <+3>: movq   %rsp, %r13

@pluiedev
Copy link
Member Author

I think I am colossally stupid and the previous fix actually works now somehow

@pluiedev pluiedev changed the title wechat: init wechat: init at 4.0.0.30 (linux) / 4.0.0.5 (darwin) Nov 10, 2024
@pluiedev pluiedev marked this pull request as ready for review November 10, 2024 09:32
@pluiedev
Copy link
Member Author

Now that both this PR and #354355 are working we have to pick one to go ahead — IMO working with .debs is more convenient than unpacking AppImages (and it also allows us to support Loongarch), and the overall deriv is much simpler this way

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/4819

@KiaraGrouwstra
Copy link
Contributor

KiaraGrouwstra commented Nov 10, 2024

nixpkgs-review somehow gets me:

          109|   installPhase =
             |   ^
          110|     ''

       error: cannot coerce a list to a string

.. seemingly over the concatenation stuff going on there

@UlyssesZh
Copy link
Member

Use lib.optionalString instead.

@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Nov 10, 2024
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. labels Nov 15, 2024
@KiaraGrouwstra
Copy link
Contributor

$ results/wechat-x86_64-linux/bin/wechat
[1]    2181620 IOT instruction (core dumped)  results/wechat-x86_64-linux/bin/wechat

😿

@pluiedev
Copy link
Member Author

$ results/wechat-x86_64-linux/bin/wechat
[1]    2181620 IOT instruction (core dumped)  results/wechat-x86_64-linux/bin/wechat

😿

Can you run lldb? I've been using it for a few days now locally and it hasn't crashed on me yet 🤔

@UlyssesZh
Copy link
Member

It doesn't crash, but has other problems.

@KiaraGrouwstra
Copy link
Contributor

hm, i may not be sufficiently familiar with lldb:

$ results/wechat-x86_64-linux/bin/wechat                  review-shell
[1]    2457353 IOT instruction (core dumped)  results/wechat-x86_64-linux/bin/wechat
$ lldb results/wechat-x86_64-linux/bin/wechat             review-shell
(lldb) target create "results/wechat-x86_64-linux/bin/wechat"
Current executable set to '/home/kiara/.cache/nixpkgs-review/pr-354332-1/results/wechat-x86_64-linux/bin/wechat' (x86_64).
(lldb) run
Process 2457575 launched: '/home/kiara/.cache/nixpkgs-review/pr-354332-1/results/wechat-x86_64-linux/bin/wechat' (x86_64)
Process 2457575 stopped
* thread #1, name = '.wechat-wrapped', stop reason = exec
    frame #0: 0x00007ffff7fe2840 ld-linux-x86-64.so.2`_start
ld-linux-x86-64.so.2`_start:
->  0x7ffff7fe2840 <+0>: movq   %rsp, %rdi
    0x7ffff7fe2843 <+3>: callq  0x7ffff7fe3520            ; _dl_start

ld-linux-x86-64.so.2`_dl_start_user:
    0x7ffff7fe2848 <+0>: movq   %rax, %r12
    0x7ffff7fe284b <+3>: movq   %rsp, %r13
(lldb) run
There is a running process, kill it and restart?: [Y/n] n
(lldb) continue
Process 2457575 resuming
Process 2457575 stopped
* thread #1, name = '.wechat-wrapped', stop reason = signal SIGABRT
    frame #0: 0x00007ffff6ca11fc libc.so.6`__pthread_kill_implementation + 268
libc.so.6`__pthread_kill_implementation:
->  0x7ffff6ca11fc <+268>: movl   %eax, %ebx
    0x7ffff6ca11fe <+270>: negl   %ebx
    0x7ffff6ca1200 <+272>: cmpl   $0xfffff000, %eax         ; imm = 0xFFFFF000
    0x7ffff6ca1205 <+277>: movl   $0x0, %eax
(lldb) continue
Process 2457575 resuming
Process 2457575 exited with status = -1 (0xffffffff) lost connection
(lldb) continue
error: Process must be launched.

@plxty
Copy link

plxty commented Mar 11, 2025

Details about the segfault:

$ lldb ./result/bin/wechat
(lldb) target create "./result/bin/wechat"
Current executable set to '/home/leah/coding/nixpkgs/result/bin/wechat' (x86_64).
(lldb) run
Process 103844 launched: '/home/leah/coding/nixpkgs/result/bin/wechat' (x86_64)
Process 103844 stopped
* thread #43, name = 'mmui::utility::', stop reason = signal SIGSEGV: address not mapped to object (fault address: 0x10)
    frame #0: 0x000055555e510008 wechat`___lldb_unnamed_symbol227806 + 232
wechat`___lldb_unnamed_symbol227806:
->  0x55555e510008 <+232>: movq   0x10(%rax), %rdx
    0x55555e51000c <+236>: addq   %rax, %rdx
    0x55555e51000f <+239>: movl   0x4(%rax), %eax
    0x55555e510012 <+242>: orq    %rax, %rbx

What I found is when a message is arrived, the wechat will SIGSEGV immediatly.

After digging for a while, I find the pulseaudio may be the cause, the gdb shows the segfault stackframe contains error log about pulseaudio,

 (gdb) x/150bc $rsi-0x50
0x560aabe1d67e:	77 'M'	69 'E'	83 'S'	0 '\000'	91 '['	37 '%'	115 's'	93 ']'
0x560aabe1d686:	91 '['	37 '%'	115 's'	58 ':'	37 '%'	100 'd'	93 ']'	0 '\000'
0x560aabe1d68e:	80 'P'	117 'u'	108 'l'	115 's'	101 'e'	65 'A'	117 'u'	100 'd'
0x560aabe1d696:	105 'i'	111 'o'	83 'S'	121 'y'	115 's'	116 't'	101 'e'	109 'm'
0x560aabe1d69e:	58 ':'	58 ':'	111 'o'	112 'p'	101 'e'	110 'n'	95 '_'	114 'r'
0x560aabe1d6a6:	101 'e'	99 'c'	111 'o'	114 'r'	100 'd'	95 '_'	115 's'	116 't'
0x560aabe1d6ae:	114 'r'	101 'e'	97 'a'	109 'm'	32 ' '	102 'f'	97 'a'	105 'i'
0x560aabe1d6b6:	108 'l'	101 'e'	100 'd'	44 ','	32 ' '	115 's'	116 't'	114 'r'
0x560aabe1d6be:	101 'e'	97 'a'	109 'm'	32 ' '	105 'i'	115 's'	32 ' '	110 'n'
0x560aabe1d6c6:	117 'u'	108 'l'	108 'l'	112 'p'	116 't'	114 'r'	46 '.'	0 '\000'
0x560aabe1d6ce:	119 'w'	119 'w'	107 'k'	32 ' '	112 'p'	108 'l'	97 'a'	121 'y'
0x560aabe1d6d6:	32 ' '	115 's'	116 't'	114 'r'	101 'e'	97 'a'	109 'm'	0 '\000'
0x560aabe1d6de:	112 'p'	97 'a'	95 '_'	99 'c'	111 'o'	110 'n'	116 't'	101 'e'
0x560aabe1d6e6:	120 'x'	116 't'	95 '_'	110 'n'	101 'e'	119 'w'	95 '_'	119 'w'
0x560aabe1d6ee:	105 'i'	116 't'	104 'h'	95 '_'	112 'p'	114 'r'	111 'o'	112 'p'
0x560aabe1d6f6:	108 'l'	105 'i'	115 's'	116 't'	0 '\000'	112 'p'	97 'a'	95 '_'
0x560aabe1d6fe:	112 'p'	114 'r'	111 'o'	112 'p'	108 'l'	105 'i'	115 's'	116 't'
0x560aabe1d706:	95 '_'	103 'g'	101 'e'	116 't'	115 's'	0 '\000'	112 'p'	97 'a'
0x560aabe1d70e:	95 '_'	115 's'	97 'a'	109 'm'	112 'p'	108 'l'

For solution, I add the libpulseaudio to LD_LIBRARY_PATH, and it seems to work now,

    wrapProgram $out/wechat/wechat \
      --prefix LD_LIBRARY_PATH : ${
        lib.makeLibraryPath [
          libGL
          udev
          libpulseaudio
        ]
      }

https://github.com/plxty/n9/blob/1fc4d59eb29b16ed765740b3964154dbd3567883/pkgs/wechat.nix#L115-L122

And the udev is for electron (the wechat applet) to work without SIGABRT.

@Prince213
Copy link
Member

#416642

@Prince213 Prince213 closed this Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: darwin Running or building packages on Darwin 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Package request: WeChat

6 participants