-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed with convert .pyrdp to .mp4: Segmentation fault in GDI Glyph #428
Comments
I get a segmentation fault with your pyrdp file on my Python 3.10 Linux environment at the same location:
Using the built-in faulthandler module we can get a little more context around the crash:
I think we pass data that is too large to the I tried on another capture file and I'm not getting a hit on that line of code however... Your server is Windows 7 and do you have the logs for when you recorded that session? I am looking for warning-level log lines that says "One or more unimplemented drawing orders called!". If I know which one I could implement it. |
I can't find "One or more unimplemented drawing orders called!" log, when set -L DEBUG eg:
|
This patch should do the trick: diff --git a/bin/pyrdp-convert.py b/bin/pyrdp-convert.py
index b87b80b..0ffd3d4 100755
--- a/bin/pyrdp-convert.py
+++ b/bin/pyrdp-convert.py
@@ -63,6 +63,10 @@ if __name__ == "__main__":
if not HAS_GUI and args.format == "mp4":
sys.stderr.write("Error: MP4 conversion requires the full PyRDP installation.")
sys.exit(1)
+ elif HAS_GUI and args.format == "mp4":
+ # Initialize QT because QPixmap relies on it
+ from PySide2.QtWidgets import QApplication
+ app = QApplication()
logging.basicConfig(level=logging.CRITICAL)
logging.getLogger("scapy").setLevel(logging.ERROR)
diff --git a/pyrdp/player/gdi/cache.py b/pyrdp/player/gdi/cache.py
index 34ff73b..7cb6e90 100644
--- a/pyrdp/player/gdi/cache.py
+++ b/pyrdp/player/gdi/cache.py
@@ -10,7 +10,7 @@ GDI Cache Management Layer.
from typing import List
from PySide2.QtCore import QSize
-from PySide2.QtGui import QBrush, QImage, QBitmap
+from PySide2.QtGui import QBrush, QImage, QBitmap, QPixmap
from pyrdp.parser.rdp.orders.common import Glyph
@@ -146,7 +146,10 @@ class GlyphEntry:
self.w = glyph.w
self.h = glyph.h
- self.bitmap = QBitmap.fromData(QSize(self.w, self.h), glyph.data, QImage.Format_Mono)
+ #import ipdb; ipdb.set_trace()
+ i = QImage(glyph.data, self.w, self.h, QImage.Format_Mono)
+ self.bitmap = QPixmap.fromImageInPlace(i)
+ #self.bitmap = QBitmap.fromData(QSize(self.w, self.h), glyph.data, QImage.Format_Mono)
class GlyphCache: With this patch I was able to convert your pyrdp file successfully and I confirmed that it didn't slow down other conversion jobs. I will commit a slightly cleaner version tomorrow. |
The fix is not correct. It no longer crashes but the video is corrupted. Check a screenshot of the converted video: Here is a screenshot of and here without the patch applied (notice that it doesn't segfault like Somehow the fix introduces visual corruption. |
Turns out that only the QT initialization part was required to avoid the segfault. I can keep using |
It's a weird fix but other attempts lead to video corruption see ticket for details.
It's a weird fix but other attempts lead to video corruption see ticket for details. Tests started failing in CI so the QT_QPA_PLATFORM environment variable trick was required to avoid that.
demo.zip
Env: win7
π pyrdp file(in demo.zip ) convert to mp4 file failed (may be python process breakdown).
The text was updated successfully, but these errors were encountered: